From 6600d22461ccc1cb602f238a9ffa83cf07dd830e Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 01 Jul 2019 18:04:02 -0400 Subject: [PATCH] Get icons 256x256 --- ObjEditor.java | 14 +- ScriptNode.java | 14 +- CameraPane.java | 50 ++++++------ GroupEditor.java | 6 cFileSystemModel.java | 85 +++++++++++++++----- cTools.java | 57 +++++++++++++- 6 files changed, 156 insertions(+), 70 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index e8d7b60..d0c68fd 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -2065,7 +2065,7 @@ //System.err.println("Oeil on"); OEIL = true; if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); //pingthread.StepToTarget(true); } @@ -11527,7 +11527,7 @@ if ((TRACK || SHADOWTRACK) || zoomonce) { if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); pingthread.StepToTarget(true); // true); // zoomonce = false; } @@ -13943,7 +13943,7 @@ // fev 2014??? if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); pingthread.StepToTarget(true); // true); } // if (!LIVE) @@ -15190,17 +15190,17 @@ case '=': IncDepth(); //fontsize += 1; - object.editWindow.refreshContents(true); + object.GetWindow().refreshContents(true); maskbit = 6; break; case '-': //if (PixelThreshold>1) PixelThreshold /= 2; DecDepth(); maskbit = 5; //if(fontsize > 1) fontsize -= 1; - if (object.editWindow == null) - new Exception().printStackTrace(); - else - object.editWindow.refreshContents(true); +// if (object.editWindow == null) +// new Exception().printStackTrace(); +// else + object.GetWindow().refreshContents(true); break; case '{': manipCamera.shaper_fovy /= 1.1; @@ -15424,7 +15424,7 @@ } */ - object.editWindow.EditSelection(false); + object.GetWindow().EditSelection(false); } void SelectParent() @@ -15441,10 +15441,10 @@ { //selectees.remove(i); System.out.println("select parent of " + elem); - group.editWindow.Select(elem.parent.GetTreePath(), first, true); + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); } else { - group.editWindow.Select(elem.GetTreePath(), first, true); + group.GetWindow().Select(elem.GetTreePath(), first, true); } first = false; @@ -15486,12 +15486,12 @@ for (int j = 0; j < group.children.size(); j++) { elem = (Object3D) group.children.elementAt(j); - object.editWindow.Select(elem.GetTreePath(), first, true); + object.GetWindow().Select(elem.GetTreePath(), first, true); first = false; } } else { - object.editWindow.Select(elem.GetTreePath(), first, true); + object.GetWindow().Select(elem.GetTreePath(), first, true); } first = false; @@ -15502,21 +15502,21 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.loadClipboard(true); // ClearSelection(false); + group.GetWindow().loadClipboard(true); // ClearSelection(false); } void ResetTransform(int mask) { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.ResetTransform(mask); + group.GetWindow().ResetTransform(mask); } void FlipTransform() { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.FlipTransform(); + group.GetWindow().FlipTransform(); // group.editWindow.ReduceMesh(true); } @@ -15524,7 +15524,7 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.PrintMemory(); + group.GetWindow().PrintMemory(); // group.editWindow.ReduceMesh(true); } @@ -15532,7 +15532,7 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.ResetCentroid(); + group.GetWindow().ResetCentroid(); } void IncDepth() @@ -16724,7 +16724,7 @@ } if (!movingcamera && !PAINTMODE) - object.editWindow.ScreenFitPoint(); // fev 2014 + object.GetWindow().ScreenFitPoint(); // fev 2014 if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) { @@ -16736,17 +16736,17 @@ group.add(paintobj); // link - object.editWindow.SnapObject(group); + object.GetWindow().SnapObject(group); - Object3D folder = object.editWindow.copy; + Object3D folder = object.GetWindow().copy; - if (object.editWindow.copy.selection.Size() > 0) - folder = object.editWindow.copy.selection.elementAt(0); + if (object.GetWindow().copy.selection.Size() > 0) + folder = object.GetWindow().copy.selection.elementAt(0); folder.add(group); - object.editWindow.ResetModel(); - object.editWindow.refreshContents(); + object.GetWindow().ResetModel(); + object.GetWindow().refreshContents(); } else paintcount = 0; diff --git a/GroupEditor.java b/GroupEditor.java index 847a6e0..dab62a9 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -1472,8 +1472,8 @@ animationItem.addItemListener(this); animationItem.setState(Globals.ANIMATION); - menu.add(archiveItem = new CheckboxMenuItem("Archive3D...")); - archiveItem.addItemListener(this); + menu.add(archiveItem = new MenuItem("Archive3D...")); + archiveItem.addActionListener(this); menu.add("-"); parseverticesItem = menu.add(new MenuItem("Multiplicity")); @@ -4734,7 +4734,7 @@ void refreshContents(boolean cp) { if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info")) - if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING) + if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING) { objEditor.ClearInfo(); // .GetMaterial()); diff --git a/ObjEditor.java b/ObjEditor.java index 1779397..93548e1 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -449,7 +449,7 @@ // TEXTAREA infoarea.setLineWrap(true); // TEXTAREA infoarea.setWrapStyleWord(true); infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); - //infoPanel.setPreferredSize(new Dimension(50, 200)); + infoPanel.setPreferredSize(new Dimension(1, 1)); infoPanel.setName("Info"); //infoPanel.setLayout(new BorderLayout()); //infoPanel.add(createTextPane()); @@ -1494,7 +1494,7 @@ // objectPanel.add(north); objectPanel.add(editPanel); - if (Globals.ADVANCED) + //if (Globals.ADVANCED) objectPanel.add(infoPanel); objectPanel.add(toolboxPanel); @@ -3201,10 +3201,6 @@ { ToggleAnimation(); return; - } else if (event.getSource() == archiveItem) - { - cTools.Archive(frame); - return; } else if (event.getSource() == flipVCB) { copy.flipV ^= true; @@ -3425,6 +3421,10 @@ { generatePOV(); //return true; + } else if (event.getSource() == archiveItem) + { + cTools.Archive(frame); + return; } else if (source == zBufferItem) { try @@ -5035,7 +5035,7 @@ CheckboxMenuItem toggleSwitchItem; CheckboxMenuItem toggleRootItem; CheckboxMenuItem animationItem; - CheckboxMenuItem archiveItem; + MenuItem archiveItem; CheckboxMenuItem toggleHandleItem; CheckboxMenuItem togglePaintItem; JSplitPane mainPanel; diff --git a/ScriptNode.java b/ScriptNode.java index 62954c9..269b6be 100644 --- a/ScriptNode.java +++ b/ScriptNode.java @@ -388,7 +388,7 @@ { System.err.println("LoadBVHFile = " + obj + "; name = " + iname + "; first frame = " + firstframe + "; last frame = " + lastframe); obj.blockloop = false; // to force crash right now - GetRoot().editWindow.LoadBVHFile(iname, obj, false, force?firstframe:-1, lastframe); + GetRoot().GetWindow().LoadBVHFile(iname, obj, false, force?firstframe:-1, lastframe); } else { @@ -522,7 +522,7 @@ if (command.equals("recompile")) { // TODO assert (GetRoot() == Globals.theRenderer.object); - GetRoot().editWindow.Recompile(); + GetRoot().GetWindow().Recompile(); return; } if (command.equals("resetframecount")) @@ -533,7 +533,7 @@ if (command.equals("deselect") || command.equals("unselect")) { // TODO assert (GetRoot() == Globals.theRenderer.object); - GetRoot().editWindow.jTree.clearSelection(); + GetRoot().GetWindow().jTree.clearSelection(); return; } if (command.equals("stoplive") || command.equals("liveoff")) @@ -771,7 +771,7 @@ if (!CameraPane.BOXMODE) { Globals.theRenderer.ToggleBoxMode(); - GetRoot().editWindow.Recompile(); + GetRoot().GetWindow().Recompile(); } return; } @@ -780,7 +780,7 @@ if (CameraPane.BOXMODE) { Globals.theRenderer.ToggleBoxMode(); - GetRoot().editWindow.Recompile(); + GetRoot().GetWindow().Recompile(); } return; } @@ -1172,7 +1172,7 @@ Object3D root = GetObject(rootobject); System.err.println("ZOOM: root = " + root + "; rootobject = " + rootobject); - GetRoot().editWindow.objEditor.ScreenFit(root, false); + GetRoot().GetWindow().objEditor.ScreenFit(root, false); CameraPane.trackedobject = root; CameraPane.ABORTED = true; System.err.println("SET ABORTED (SPEAKERFOCUS) "); @@ -1464,7 +1464,7 @@ { // TODO assert (GetRoot() == Globals.theRenderer.object); String path = GetAlias(strs[index+1]); - GetRoot().editWindow.Select(GetRoot().GetTreePath(path.split("/"), 0), false, false); + GetRoot().GetWindow().Select(GetRoot().GetTreePath(path.split("/"), 0), false, false); return; } if (command.equals("mocap")) diff --git a/cFileSystemModel.java b/cFileSystemModel.java index 631ad57..98d4aad 100644 --- a/cFileSystemModel.java +++ b/cFileSystemModel.java @@ -113,35 +113,74 @@ 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 (true) { - 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"); - } - } - + // Small icons + String valueTruncated = valueString.substring(0, valueString.length()-4); + + System.out.println(valueTruncated); + + javax.swing.ImageIcon rendererIcon = icons.get(valueTruncated); + if (rendererIcon == null) { - rendererIcon = new javax.swing.ImageIcon(); + 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 + { + // Large icons + String[] split = valueString.split("/"); + + String valueTruncated = ""; + + for (int i=1; i<split.length-1; i++) + { + valueTruncated += "/" + split[i]; } - icons.put(valueTruncated, rendererIcon); + valueTruncated += "/icon.jpg"; + + System.out.println(valueTruncated); + + javax.swing.ImageIcon rendererIcon = icons.get(valueTruncated); + + if (rendererIcon == null) + { + if (new File(valueTruncated).exists()) + { + rendererIcon = new javax.swing.ImageIcon(valueTruncated); + } + + if (rendererIcon == null) + { + rendererIcon = new javax.swing.ImageIcon(); + } + + icons.put(valueTruncated, rendererIcon); + } + + setIcon(rendererIcon); } - - setIcon(rendererIcon); } else { diff --git a/cTools.java b/cTools.java index b48b0c1..03650a5 100644 --- a/cTools.java +++ b/cTools.java @@ -1,6 +1,7 @@ import java.io.*; import java.awt.*; +import java.net.URL; import java.util.zip.ZipInputStream; public class cTools @@ -15,6 +16,16 @@ java.net.URL u; InputStream is = null; + + if (new File(location).exists()) + { + // Already downloaded + System.out.println(location + ": Already downloaded"); + + GetIcon(icon, location, "icon"); + + return; + } java.util.zip.ZipInputStream zis; @@ -39,13 +50,13 @@ if (entryName.endsWith(".gsm")) { // ArchiCAD - // continue; + continue; } if (entryName.endsWith(".max")) { // 3DS MAX - // continue; + continue; } if (entryName.endsWith(".3ds") || entryName.endsWith(".obj")) @@ -63,6 +74,8 @@ // reading until read returns 0 or less. String outpath = location + "/" + entry.getName(); + //new java.io.File(outpath).mkdirs(); + TransferFile(outpath, zis); } } catch (java.net.MalformedURLException mue) @@ -72,8 +85,13 @@ //System.exit(2); } catch (IOException ioe) { - //System.err.println("Oops - an IOException happened."); - //ioe.printStackTrace(); + System.err.println("Oops - an IOException happened."); + ioe.printStackTrace(); + //System.exit(3); + } catch (IllegalArgumentException iae) + { + System.err.println("Oops - an IllegalArgumentException happened."); + iae.printStackTrace(); //System.exit(3); } finally { @@ -114,6 +132,35 @@ modelName = modelName.substring(0, modelName.length() - 4); TransferFile(location + "/" + modelName + ".jpg", is); + + GetIcon(icon, location, "icon"); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + private static void GetIcon(String icon, String location, String iconName) + { + URL u; + InputStream is; + try + { + //icon = https://storage3d.com/storage/2008.08/resized/7142f85f2575b35078f15feddaf8b315_64x64.jpg + + String[] split = icon.split("resized/"); + + icon = split[0] + split[1]; + + split = icon.split("_64x64"); + + icon = split[0] + ".jpg"; + + u = new java.net.URL(icon); + is = u.openStream(); + + TransferFile(location + "/" + iconName + ".jpg", is); } catch (Exception e) { @@ -201,7 +248,7 @@ GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", browser.getDirectory() + "/" + cat, id, name, icon); // To avoid network overload. - Thread.sleep(2000); + Thread.sleep(1000); } file.close(); -- Gitblit v1.6.2