From 9079880942d022ee32fd3a543843e132e52deb1a Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 30 Jun 2019 23:52:19 -0400 Subject: [PATCH] Tree icons. --- ObjEditor.java | 30 + /dev/null | 352 -------------------- CameraPane.java | 128 ------- cTreeModel.java | 127 +++--- GroupEditor.java | 3 cFileSystemModel.java | 112 ++++- cTools.java | 214 ++++++++++++ 7 files changed, 381 insertions(+), 585 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index cdf2ce1..e8d7b60 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -2398,128 +2398,6 @@ return currentGL; } - private void GetRemoteZip(String url, String name, boolean unzip, boolean save) - { - java.net.URL u; - InputStream is = null; - DataInputStream dis; - java.util.zip.ZipInputStream zis; - //String s; - - System.out.println("GetRemoteZip " + name); - - int total = 0; // dis.available(); - - byte[] bytes = new byte[16384]; - - try - { - u = new java.net.URL(url + name); - is = u.openStream(); - - System.out.println(url + name); - - if (unzip) - { - //dis = new DataInputStream(new BufferedInputStream(is)); - zis = new java.util.zip.ZipInputStream(new BufferedInputStream(is)); - //while ((s = dis.readLine()) != null) - - if (save) - new java.io.File(name).mkdirs(); - - // FileOutputStream stream = new FileOutputStream("test.zip"); - // - // int count; - // - // while ((count = dis.read(bytes)) != -1) - // { - // //System.out.println(s); - // System.out.println(count); - // total += count; - // stream.write(bytes); - // } - // - // stream.close(); - - // now iterate through each item in the stream. The get next - // entry call will return a ZipEntry for each file in the - // stream - java.util.zip.ZipEntry entry; - while((entry = zis.getNextEntry())!=null) - { - if (entry.getName().endsWith(".gsm")) - { - continue; - } - - String s = String.format("Entry: %s len %d added %TD", - entry.getName(), entry.getSize(), - new java.util.Date(entry.getTime())); - System.out.println(s); - - if (save) - { - // Once we get the entry from the stream, the stream is - // positioned read to read the raw data, and we keep - // reading until read returns 0 or less. - String outpath = name + "/" + entry.getName(); - FileOutputStream output = null; - try - { - output = new FileOutputStream(outpath); - int len = 0; - while ((len = zis.read(bytes)) > 0) - { - output.write(bytes, 0, len); - } - } - finally - { - // we must always close the output file - if(output!=null) output.close(); - } - } - } - } - } - catch (java.net.MalformedURLException mue) - { - System.err.println("Ouch - a MalformedURLException happened."); - mue.printStackTrace(); - //System.exit(2); - } - catch (IOException ioe) - { - //System.err.println("Oops - an IOException happened."); - //ioe.printStackTrace(); - //System.exit(3); - } - finally - { - try - { - if (is != null) - is.close(); - } - catch (IOException ioe) - { - } - } - - // System.out.println("length = " + total); - -// try -// { -// Runtime.getRuntime().exec("/usr/local/bin/wget https://archive3d.net/?a=download&do=get&id=7caca905"); -// } -// catch (Exception e) -// { -// e.printStackTrace(); -// } - - } - /**/ class CacheTexture { @@ -15295,12 +15173,6 @@ break; case '+': - //for (int i=0; i<0x7FFFFFFF; i++) - { - //String.format("%08X", i); // "7caca905" - GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", "7caca905", true, true); - } - /* //fontsize += 1; bbzoom *= 2; diff --git a/GroupEditor.java b/GroupEditor.java index 776ef38..847a6e0 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -1472,6 +1472,9 @@ animationItem.addItemListener(this); animationItem.setState(Globals.ANIMATION); + menu.add(archiveItem = new CheckboxMenuItem("Archive3D...")); + archiveItem.addItemListener(this); + menu.add("-"); parseverticesItem = menu.add(new MenuItem("Multiplicity")); parseverticesItem.addActionListener(this); diff --git a/ObjEditor.java b/ObjEditor.java index b938e7a..1779397 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -350,7 +350,7 @@ frame.setMenuBar(menuBar = new MenuBar()); menuBar.add(fileMenu = new Menu("File")); fileMenu.add(newItem = new MenuItem("New")); - fileMenu.add(loadItem = new MenuItem("Open...")); + fileMenu.add(openItem = new MenuItem("Open...")); //oe.menuBar.add(menu = new Menu("Include")); Menu menu = new Menu("Import"); @@ -382,7 +382,7 @@ } newItem.addActionListener(this); - loadItem.addActionListener(this); + openItem.addActionListener(this); saveItem.addActionListener(this); saveAsItem.addActionListener(this); exportAsItem.addActionListener(this); @@ -780,7 +780,7 @@ // X frame.getContentPane().remove(/*"Center",*/bigThree); // X framePanel.add(bigThree); // X frame.getContentPane().add(/*"Center",*/framePanel); - framePanel.setDividerLocation(1); + framePanel.setDividerLocation(46); //frame.setVisible(true); radio.layout = keepButton; @@ -1493,7 +1493,10 @@ // north.add(ctrlPanel, BorderLayout.NORTH); // objectPanel.add(north); objectPanel.add(editPanel); - objectPanel.add(infoPanel); + + if (Globals.ADVANCED) + objectPanel.add(infoPanel); + objectPanel.add(toolboxPanel); /* @@ -1602,9 +1605,9 @@ // aConstraints.gridheight = 1; framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); - framePanel.setContinuousLayout(true); - framePanel.setOneTouchExpandable(true); - framePanel.setDividerLocation(0.8); + framePanel.setContinuousLayout(false); + framePanel.setOneTouchExpandable(false); + //.setDividerLocation(0.8); //framePanel.setDividerSize(15); //framePanel.setResizeWeight(0.15); framePanel.setName("Frame"); @@ -3198,6 +3201,10 @@ { ToggleAnimation(); return; + } else if (event.getSource() == archiveItem) + { + cTools.Archive(frame); + return; } else if (event.getSource() == flipVCB) { copy.flipV ^= true; @@ -3391,9 +3398,9 @@ { Close(); //return true; - } else if (source == loadItem) + } else if (source == openItem) { - load(); + Open(); //return true; } else if (source == newItem) { @@ -4720,7 +4727,7 @@ } } - void load() // throws ClassNotFoundException + void Open() // throws ClassNotFoundException { if (Grafreed.standAlone) { @@ -5005,7 +5012,7 @@ MenuBar menuBar; Menu fileMenu; MenuItem newItem; - MenuItem loadItem; + MenuItem openItem; MenuItem saveItem; MenuItem saveAsItem; MenuItem exportAsItem; @@ -5028,6 +5035,7 @@ CheckboxMenuItem toggleSwitchItem; CheckboxMenuItem toggleRootItem; CheckboxMenuItem animationItem; + CheckboxMenuItem archiveItem; CheckboxMenuItem toggleHandleItem; CheckboxMenuItem togglePaintItem; JSplitPane mainPanel; diff --git a/cFileSystemModel.java b/cFileSystemModel.java index 1748e2b..631ad57 100644 --- a/cFileSystemModel.java +++ b/cFileSystemModel.java @@ -1,10 +1,12 @@ import java.io.*; +import javax.swing.Icon; import javax.swing.event.*; import javax.swing.tree.*; class cFileSystemModel implements TreeModel { + File root; cFilter filter; @@ -23,88 +25,136 @@ { } - public Object getChild(Object parent, int index) + public Object getChild(Object parent, int index) { //new Exception().printStackTrace(); - + //System.out.println("child[" + index + "] = " + ((File) parent).listFiles(filter)[index]); - + File[] files = table.get(parent); - assert(files != null); + assert (files != null); //return ((File) parent).listFiles(filter)[index]; return files[index]; - - } + } java.util.Hashtable<File, File[]> table = new java.util.Hashtable<File, File[]>(); - - public int getChildCount(Object parent) + + public int getChildCount(Object parent) { - if( isLeaf(parent) ) + if (isLeaf(parent)) + { return 0; - else + } else { //System.out.println(parent + " childcount = " + ((File) parent).listFiles(filter).length); File[] files = table.get(parent); - - if(files == null) + + if (files == null) { files = ((File) parent).listFiles(filter); table.put(((File) parent), files); } - + return files.length; } } - public int getIndexOfChild(Object parent, Object child) + public int getIndexOfChild(Object parent, Object child) { assert false; return 0; } - public Object getRoot() + public Object getRoot() { return root; } - public boolean isLeaf(Object node) + public boolean isLeaf(Object node) { return !((File) node).isDirectory(); } - public void removeTreeModelListener(TreeModelListener l) + public void removeTreeModelListener(TreeModelListener l) { } - public void valueForPathChanged(TreePath path, Object newValue) + public void valueForPathChanged(TreePath path, Object newValue) { } + static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>(); + + static class Renderer extends DefaultTreeCellRenderer { - public Renderer() { + + public Renderer() + { } public java.awt.Component getTreeCellRendererComponent( - cTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) + //cTree tree, + javax.swing.JTree tree, + Object value, + boolean sel, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) { - System.out.println(value); + //System.out.println(value); super.getTreeCellRendererComponent( - tree, value, sel, - expanded, leaf, row, - hasFocus); + tree, value, sel, + expanded, leaf, row, + hasFocus); + + String valueString = value.toString(); + + if (valueString.toLowerCase().endsWith(".gfd") || valueString.toLowerCase().endsWith(".obj") || valueString.toLowerCase().endsWith(".3ds")) + { + String valueTruncated = valueString.substring(0, valueString.length()-4); + + System.out.println(valueTruncated); + + javax.swing.ImageIcon rendererIcon = icons.get(valueTruncated); + + if (rendererIcon == null) + { + if (new File(valueTruncated + ".jpg").exists()) + { + rendererIcon = new javax.swing.ImageIcon(valueTruncated + ".jpg"); + } + else + { + if (new File(valueTruncated + ".png").exists()) + { + rendererIcon = new javax.swing.ImageIcon(valueTruncated + ".png"); + } + } + + if (rendererIcon == null) + { + rendererIcon = new javax.swing.ImageIcon(); + } + + icons.put(valueTruncated, rendererIcon); + } + + setIcon(rendererIcon); + } + else + { + //setIcon(null); +// Icon systemIcon = javax.swing.filechooser.FileSystemView.getFileSystemView().getSystemIcon( new File(valueString) ); +// setIcon(systemIcon); + } + setToolTipText("This book is in the Tutorial series."); return this; } - + public void setText(String text) { //System.out.println(text); diff --git a/cTools.java b/cTools.java new file mode 100644 index 0000000..b48b0c1 --- /dev/null +++ b/cTools.java @@ -0,0 +1,214 @@ + +import java.io.*; +import java.awt.*; +import java.util.zip.ZipInputStream; + +public class cTools +{ + static byte[] bytes = new byte[16384]; + + static private void GetRemoteZip(String url, String dir, String id, String name, String icon) + { + String filename = name + "_" + id; + + String location = dir + "/" + filename; + + java.net.URL u; + InputStream is = null; + + java.util.zip.ZipInputStream zis; + + String modelName = null; + + try + { + u = new java.net.URL(url + id); + is = u.openStream(); + + zis = new java.util.zip.ZipInputStream(is); + + new java.io.File(location).mkdirs(); + + // now iterate through each item in the stream. The get next + // entry call will return a ZipEntry for each file in the stream + java.util.zip.ZipEntry entry; + while ((entry = zis.getNextEntry()) != null) + { + String entryName = entry.getName().toLowerCase(); + + if (entryName.endsWith(".gsm")) + { + // ArchiCAD + // continue; + } + + if (entryName.endsWith(".max")) + { + // 3DS MAX + // continue; + } + + if (entryName.endsWith(".3ds") || entryName.endsWith(".obj")) + { + modelName = entry.getName(); + } + + String s = String.format("Entry: %s len %d added %TD", + entry.getName(), entry.getSize(), + new java.util.Date(entry.getTime())); + System.out.println(s); + + // Once we get the entry from the stream, the stream is + // positioned read to read the raw data, and we keep + // reading until read returns 0 or less. + String outpath = location + "/" + entry.getName(); + + TransferFile(outpath, zis); + } + } catch (java.net.MalformedURLException mue) + { + System.err.println("Ouch - a MalformedURLException happened."); + mue.printStackTrace(); + //System.exit(2); + } catch (IOException ioe) + { + //System.err.println("Oops - an IOException happened."); + //ioe.printStackTrace(); + //System.exit(3); + } finally + { + try + { + if (is != null) + { + is.close(); + } + } catch (IOException ioe) + { + } + } + + // System.out.println("length = " + total); + +// try +// { +// Runtime.getRuntime().exec("/usr/local/bin/wget https://archive3d.net/?a=download&do=get&id=7caca905"); +// } +// catch (Exception e) +// { +// e.printStackTrace(); +// } + java.awt.image.BufferedImage image; + + try + { + u = new java.net.URL(icon); + is = u.openStream(); + +// image = (java.awt.image.BufferedImage)javax.imageio.ImageIO.read(u); +// +// //String[] g = javax.imageio.ImageIO.getWriterFormatNames(); +// +// javax.imageio.ImageIO.write(image, "jpg", new File(location + "/" + name + id + ".jpg")); + + modelName = modelName.substring(0, modelName.length() - 4); + + TransferFile(location + "/" + modelName + ".jpg", is); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + static private void TransferFile(String outpath, InputStream zis) throws IOException + { + FileOutputStream output = null; + try + { + output = new FileOutputStream(outpath); + int len = 0; + while ((len = zis.read(bytes)) > 0) + { + output.write(bytes, 0, len); + } + } finally + { + // we must always close the output file + if (output != null) + { + output.close(); + } + } + } + + static void Archive(javax.swing.JFrame frame) + { + FileDialog browser = new FileDialog(frame, "Select archive to extract...", FileDialog.LOAD); + browser.setVisible(true); + String filename = browser.getFile(); + if (filename != null && filename.length() > 0) + { + try + { + RandomAccessFile file = new RandomAccessFile(browser.getDirectory() + filename, "r"); + String str; + while ((str = file.readLine()) != null) + { + System.out.println(str); + + String cat = "nocat"; + + String[] split = str.split("category="); + + if (split.length > 1) + { + String[] split2 = split[1].split(":"); + + cat = split2[0]; + + String[] split3 = cat.split("&"); + + cat = split3[0]; + + //// + str = split2[1]; + + int i = 2; + while (i < split2.length) + { + str += ":" + split2[i++]; + } + } + + split = str.split("id="); + + str = split[1]; + split = str.split("\" title=\"Download "); + + String id = split[0]; + + str = split[1]; + split = str.split(" 3D Model\"><img src=\""); + + String name = split[0]; + + str = split[1]; + split = str.split("\" alt"); + + String icon = split[0]; + + GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", browser.getDirectory() + "/" + cat, id, name, icon); + + // To avoid network overload. + Thread.sleep(2000); + } + + file.close(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + } +} diff --git a/cTreeDirectoryModel.java b/cTreeDirectoryModel.java deleted file mode 100644 index 7325d45..0000000 --- a/cTreeDirectoryModel.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * @(#)BasicDirectoryModel.java 1.31 04/05/05 - * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -//package javax.swing.plaf.basic; - -import java.io.File; -import java.util.*; -import javax.swing.*; -import javax.swing.tree.*; -import javax.swing.filechooser.*; -import javax.swing.event.*; -import java.beans.*; - -import sun.awt.shell.ShellFolder; - -/** - * Basic implementation of a file list. - * - * @version %i% %g% - * @author Jeff Dinkins - */ -public class cTreeDirectoryModel extends DefaultTreeModel implements PropertyChangeListener { - - private JFileChooser filechooser = null; - // PENDING(jeff) pick the size more sensibly - private Vector fileCache = new Vector(50); - private LoadFilesThread loadThread = null; - private Vector files = null; - private Vector directories = null; - private int fetchID = 0; - - public cTreeDirectoryModel(JFileChooser filechooser) { - super(null); - this.filechooser = filechooser; - validateFileCache(); - } - - public void propertyChange(PropertyChangeEvent e) { - String prop = e.getPropertyName(); - if(prop == JFileChooser.DIRECTORY_CHANGED_PROPERTY || - prop == JFileChooser.FILE_VIEW_CHANGED_PROPERTY || - prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY || - prop == JFileChooser.FILE_HIDING_CHANGED_PROPERTY || - prop == JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY) { - validateFileCache(); - } - } - - /** - * Obsolete - not used. - */ - public void invalidateFileCache() { - } - - public Vector<File> getDirectories() { - synchronized(fileCache) { - if (directories != null) { - return directories; - } - Vector fls = getFiles(); - return directories; - } - } - - public Vector<File> getFiles() { - synchronized(fileCache) { - if (files != null) { - return files; - } - files = new Vector(); - directories = new Vector(); - directories.addElement(filechooser.getFileSystemView().createFileObject( - filechooser.getCurrentDirectory(), "..") - ); - - for (int i = 0; i < getSize(); i++) { - File f = (File)fileCache.get(i); - if (filechooser.isTraversable(f)) { - directories.add(f); - } else { - files.add(f); - } - } - return files; - } - } - - public void validateFileCache() { - File currentDirectory = filechooser.getCurrentDirectory(); - if (currentDirectory == null) { - return; - } - if (loadThread != null) { - loadThread.interrupt(); - loadThread.cancelRunnables(); - } - fetchID++; - loadThread = new LoadFilesThread(currentDirectory, fetchID); - loadThread.start(); - } - - /** - * Renames a file in the underlying file system. - * - * @param oldFile a <code>File</code> object representing - * the existing file - * @param newFile a <code>File</code> object representing - * the desired new file name - * @return <code>true</code> if rename succeeded, - * otherwise <code>false</code> - * @since 1.4 - */ - public boolean renameFile(File oldFile, File newFile) { - synchronized(fileCache) { - if (oldFile.renameTo(newFile)) { - validateFileCache(); - return true; - } - return false; - } - } - - - public void fireContentsChanged() { - // System.out.println("BasicDirectoryModel: firecontentschanged"); - //fireContentsChanged(this, 0, getSize()-1); - } - - public int getSize() { - return fileCache.size(); - } - - public boolean contains(Object o) { - return fileCache.contains(o); - } - - public int indexOf(Object o) { - return fileCache.indexOf(o); - } - - public Object getElementAt(int index) { - return fileCache.get(index); - } - - /** - * Obsolete - not used. - */ - public void intervalAdded(ListDataEvent e) { - } - - /** - * Obsolete - not used. - */ - public void intervalRemoved(ListDataEvent e) { - } - - protected void sort(Vector<? extends File> v){ - ShellFolder.sortFiles(v); - } - - // Obsolete - not used - protected boolean lt(File a, File b) { - // First ignore case when comparing - int diff = a.getName().toLowerCase().compareTo(b.getName().toLowerCase()); - if (diff != 0) { - return diff < 0; - } else { - // May differ in case (e.g. "mail" vs. "Mail") - return a.getName().compareTo(b.getName()) < 0; - } - } - - - class LoadFilesThread extends Thread { - File currentDirectory = null; - int fid; - Vector runnables = new Vector(10); - - public LoadFilesThread(File currentDirectory, int fid) { - super("Basic L&F File Loading Thread"); - this.currentDirectory = currentDirectory; - this.fid = fid; - } - - private void invokeLater(Runnable runnable) { - runnables.addElement(runnable); - SwingUtilities.invokeLater(runnable); - } - - public void run() { - FileSystemView fileSystem = filechooser.getFileSystemView(); - - File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled()); - - Vector<File> acceptsList = new Vector<File>(); - - if (isInterrupted()) { - return; - } - - // run through the file list, add directories and selectable files to fileCache - for (int i = 0; i < list.length; i++) { - if(filechooser.accept(list[i])) { - acceptsList.addElement(list[i]); - } - } - - if (isInterrupted()) { - return; - } - - // First sort alphabetically by filename - sort(acceptsList); - - Vector newDirectories = new Vector(50); - Vector newFiles = new Vector(); - // run through list grabbing directories in chunks of ten - for(int i = 0; i < acceptsList.size(); i++) { - File f = (File) acceptsList.elementAt(i); - boolean isTraversable = filechooser.isTraversable(f); - if (isTraversable) { - newDirectories.addElement(f); - } else if (!isTraversable && filechooser.isFileSelectionEnabled()) { - newFiles.addElement(f); - } - if(isInterrupted()) { - return; - } - } - - Vector newFileCache = new Vector(newDirectories); - newFileCache.addAll(newFiles); - - int newSize = newFileCache.size(); - int oldSize = fileCache.size(); - - if (newSize > oldSize) { - //see if interval is added - int start = oldSize; - int end = newSize; - for (int i = 0; i < oldSize; i++) { - if (!newFileCache.get(i).equals(fileCache.get(i))) { - start = i; - for (int j = i; j < newSize; j++) { - if (newFileCache.get(j).equals(fileCache.get(i))) { - end = j; - break; - } - } - break; - } - } - if (start >= 0 && end > start - && newFileCache.subList(end, newSize).equals(fileCache.subList(start, oldSize))) { - if(isInterrupted()) { - return; - } - invokeLater(new DoChangeContents(newFileCache.subList(start, end), start, null, 0, fid)); - newFileCache = null; - } - } else if (newSize < oldSize) { - //see if interval is removed - int start = -1; - int end = -1; - for (int i = 0; i < newSize; i++) { - if (!newFileCache.get(i).equals(fileCache.get(i))) { - start = i; - end = i + oldSize - newSize; - break; - } - } - if (start >= 0 && end > start - && fileCache.subList(end, oldSize).equals(newFileCache.subList(start, newSize))) { - if(isInterrupted()) { - return; - } - invokeLater(new DoChangeContents(null, 0, new Vector(fileCache.subList(start, end)), - start, fid)); - newFileCache = null; - } - } - if (newFileCache != null && !fileCache.equals(newFileCache)) { - if (isInterrupted()) { - cancelRunnables(runnables); - } - invokeLater(new DoChangeContents(newFileCache, 0, fileCache, 0, fid)); - } - } - - - public void cancelRunnables(Vector runnables) { - for(int i = 0; i < runnables.size(); i++) { - ((DoChangeContents)runnables.elementAt(i)).cancel(); - } - } - - public void cancelRunnables() { - cancelRunnables(runnables); - } - } - - class DoChangeContents implements Runnable { - private List addFiles; - private List remFiles; - private boolean doFire = true; - private int fid; - private int addStart = 0; - private int remStart = 0; - private int change; - - public DoChangeContents(List addFiles, int addStart, List remFiles, int remStart, int fid) { - this.addFiles = addFiles; - this.addStart = addStart; - this.remFiles = remFiles; - this.remStart = remStart; - this.fid = fid; - } - - synchronized void cancel() { - doFire = false; - } - - public synchronized void run() { - if (fetchID == fid && doFire) { - int remSize = (remFiles == null) ? 0 : remFiles.size(); - int addSize = (addFiles == null) ? 0 : addFiles.size(); - synchronized(fileCache) { - if (remSize > 0) { - fileCache.removeAll(remFiles); - } - if (addSize > 0) { - fileCache.addAll(addStart, addFiles); - } - files = null; - directories = null; - } - if (remSize > 0 && addSize == 0) { - //fireIntervalRemoved(BasicDirectoryModel.this, remStart, remStart + remSize - 1); - } else if (addSize > 0 && remSize == 0 && fileCache.size() > addSize) { - //fireIntervalAdded(BasicDirectoryModel.this, addStart, addStart + addSize - 1); - } else { - fireContentsChanged(); - } - } - } - } -} - diff --git a/cTreeModel.java b/cTreeModel.java index e5f99c4..85f893d 100644 --- a/cTreeModel.java +++ b/cTreeModel.java @@ -8,101 +8,100 @@ public cTreeModel(Object3D owner) { - root = owner; + root = owner; } public void addTreeModelListener(TreeModelListener l) { } - public Object getChild(Object parent, int index) + public Object getChild(Object parent, int index) { - Object3D /*Composite*/ group = (Object3D /*Composite*/) parent; + Object3D /*Composite*/ group = (Object3D /*Composite*/) parent; - return group./*children.*/get(index); + return group./*children.*/get(index); } - public int getChildCount(Object parent) + public int getChildCount(Object parent) { - //if (parent instanceof Composite) - { - return ((Object3D /*Composite*/) parent)/*.children*/.Size(); - } + //if (parent instanceof Composite) + { + return ((Object3D /*Composite*/) parent)/*.children*/.Size(); + } - //return 0; + //return 0; } - public int getIndexOfChild(Object parent, Object child) + public int getIndexOfChild(Object parent, Object child) { - Object3D /*Composite*/ group = (Object3D /*Composite*/) parent; + Object3D /*Composite*/ group = (Object3D /*Composite*/) parent; - return group./*GetObject().*/indexOf(child); + return group./*GetObject().*/indexOf(child); } - public Object getRoot() + public Object getRoot() { - return root; + return root; } - public boolean isLeaf(Object node) + public boolean isLeaf(Object node) { - return ((Object3D)node).Size() == 0; // !(node instanceof Composite); + return ((Object3D) node).Size() == 0; // !(node instanceof Composite); } - public void removeTreeModelListener(TreeModelListener l) + public void removeTreeModelListener(TreeModelListener l) { } - public void valueForPathChanged(TreePath path, Object newValue) + public void valueForPathChanged(TreePath path, Object newValue) { } static class Renderer extends DefaultTreeCellRenderer { - public Renderer() { + public Renderer() + { } public java.awt.Component getTreeCellRendererComponent( - javax.swing.JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) + javax.swing.JTree tree, + Object value, + boolean sel, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) { //System.out.println(value.getClass()); - super.getTreeCellRendererComponent( - tree, value, sel, - expanded, leaf, row, - hasFocus); - String stringValue = tree.convertValueToText(value, sel, - expanded, leaf, row, hasFocus); + super.getTreeCellRendererComponent(tree, value, sel, + expanded, leaf, row, hasFocus); + String stringValue = tree.convertValueToText(value, sel, + expanded, leaf, row, hasFocus); - //this.tree = tree; - this.hasFocus = hasFocus; - setText(stringValue); + //this.tree = tree; + this.hasFocus = hasFocus; + setText(stringValue); - Object3D obj = (Object3D) value; - - int r = 0, g = 0, b = 0; + Object3D obj = (Object3D) value; - if (obj.live) - { - g = 192; - } - - if (obj.hide) - { - r = 192; - } - - if (obj.link2master) - { - b = 192; - } - - java.awt.Color fg = new java.awt.Color(r,g,b); + int r = 0, g = 0, b = 0; + + if (obj.live) + { + g = 192; + } + + if (obj.hide) + { + r = 192; + } + + if (obj.link2master) + { + b = 192; + } + + java.awt.Color fg = new java.awt.Color(r, g, b); // isDropCell = false; // JTree.DropLocation dropLocation = tree.getDropLocation(); @@ -126,9 +125,9 @@ // } // setBackground(fg); - setForeground(fg); + setForeground(fg); - // There needs to be a way to specify disabled icons. + // There needs to be a way to specify disabled icons. // if (!tree.isEnabled()) { // setEnabled(false); // @@ -152,20 +151,22 @@ // } // } - setComponentOrientation(tree.getComponentOrientation()); + setComponentOrientation(tree.getComponentOrientation()); - selected = sel; + selected = sel; //Object3D obj = (Object3D) value; - - if(obj.material == null) + + if (obj.material == null) + { setIcon(null); - + } + setToolTipText("This book is in the Tutorial series."); return this; } - + public void setText(String text) { //System.out.println(text); -- Gitblit v1.6.2