Normand Briere
2019-06-24 47cd0f0a3870d843cb758535316060d30f15c811
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -37,6 +38,65 @@
3738 JFrame frame;
3839
3940 static ObjEditor theFrame;
41
+
42
+ cButton GetButton(String name, boolean border)
43
+ {
44
+ try
45
+ {
46
+ ImageIcon icon = GetIcon(name);
47
+ return new cButton(icon, border);
48
+ }
49
+ catch (Exception e)
50
+ {
51
+ return new cButton(name, border);
52
+ }
53
+ }
54
+
55
+ cToggleButton GetToggleButton(String name, boolean border)
56
+ {
57
+ try
58
+ {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cToggleButton(icon, border);
61
+ }
62
+ catch (Exception e)
63
+ {
64
+ return new cToggleButton(name, border);
65
+ }
66
+ }
67
+
68
+ cCheckBox GetCheckBox(String name, boolean border)
69
+ {
70
+ try
71
+ {
72
+ ImageIcon icon = GetIcon(name);
73
+ return new cCheckBox(icon, border);
74
+ }
75
+ catch (Exception e)
76
+ {
77
+ return new cCheckBox(name, border);
78
+ }
79
+ }
80
+
81
+ private ImageIcon GetIcon(String name) throws IOException
82
+ {
83
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
+
85
+ if (image.getWidth() != 24 && image.getHeight() != 24)
86
+ {
87
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
+ Graphics2D g = resized.createGraphics();
89
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
+ g.dispose();
93
+
94
+ image = resized;
95
+ }
96
+
97
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
+ return icon;
99
+ }
40100
41101 // SCRIPT
42102
....@@ -337,9 +397,12 @@
337397 editPanel.add(editCommandsPanel);
338398 editPanel.add(ctrlPanel);
339399
340
- materialPanel = new cGridBag().setVertical(true);
400
+ toolboxPanel = new cGridBag().setVertical(false);
401
+ toolboxPanel.setName("Toolbox");
341402
403
+ materialPanel = new cGridBag().setVertical(true);
342404 materialPanel.setName("Material");
405
+
343406 /*JTextPane*/
344407 infoarea = createTextPane();
345408 doc = infoarea.getStyledDocument();
....@@ -612,6 +675,8 @@
612675
613676 boolean maximized;
614677
678
+ cButton fullscreenLayout;
679
+
615680 void Minimize()
616681 {
617682 frame.setState(Frame.ICONIFIED);
....@@ -673,7 +738,7 @@
673738 // X frame.getContentPane().add(/*"Center",*/bigThree);
674739 framePanel.setDividerLocation(0);
675740
676
- radio.layout = twoButton;
741
+ radio.layout = fullscreenLayout;
677742 radio.layout.doClick();
678743 //frame.setVisible(true);
679744 }
....@@ -1347,6 +1412,7 @@
13471412
13481413 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13491414 //tmp.setName("Edit");
1415
+ objectPanel.add(toolboxPanel);
13501416 objectPanel.add(materialPanel);
13511417 // JPanel north = new JPanel(new BorderLayout());
13521418 // north.setName("Edit");
....@@ -3408,6 +3474,8 @@
34083474
34093475 public void Save()
34103476 {
3477
+ System.err.println("Save");
3478
+
34113479 cRadio tab = GetCurrentTab();
34123480
34133481 boolean temp = CameraPane.SWITCH;
....@@ -3492,6 +3560,8 @@
34923560
34933561 public void Undo()
34943562 {
3563
+ System.err.println("Undo");
3564
+
34953565 cRadio tab = GetCurrentTab();
34963566
34973567 if (tab.undoindex == 0)
....@@ -3675,7 +3745,7 @@
36753745 assert false;
36763746 }
36773747
3678
- void EditSelection()
3748
+ void EditSelection(boolean newWindow)
36793749 {
36803750 }
36813751
....@@ -4170,7 +4240,8 @@
41704240
41714241 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41724242 {
4173
- Save();
4243
+ if (Globals.SAVEONMAKE) // && resetmodel)
4244
+ Save();
41744245 //Tween.set(thing, 0).target(1).start(tweenManager);
41754246 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41764247 // if (thing instanceof GenericJointDemo)
....@@ -4257,6 +4328,12 @@
42574328 {
42584329 ResetModel();
42594330 Select(thing.GetTreePath(), true, false); // unselect... false);
4331
+
4332
+ if (thing.Size() == 0)
4333
+ {
4334
+ //EditSelection(false);
4335
+ }
4336
+
42604337 refreshContents();
42614338 }
42624339
....@@ -4479,6 +4556,7 @@
44794556
44804557 if (readobj != null)
44814558 {
4559
+ if (Globals.SAVEONMAKE)
44824560 Save();
44834561 try
44844562 {
....@@ -4850,18 +4928,29 @@
48504928 CheckboxMenuItem togglePaintItem;
48514929 JSplitPane mainPanel;
48524930 JScrollPane scrollpane;
4931
+
48534932 JPanel toolbarPanel;
4933
+
48544934 cGridBag treePanel;
4935
+
48554936 JPanel radioPanel;
48564937 ButtonGroup buttonGroup;
4857
- cGridBag ctrlPanel;
4938
+
4939
+ cGridBag toolboxPanel;
48584940 cGridBag materialPanel;
4941
+ cGridBag ctrlPanel;
4942
+
48594943 JScrollPane infoPanel;
4944
+
48604945 cGridBag optionsPanel;
4946
+
48614947 JTabbedPane objectPanel;
4948
+
48624949 cGridBag XYZPanel;
4950
+
48634951 JSplitPane gridPanel;
48644952 JSplitPane bigPanel;
4953
+
48654954 cGridBag bigThree;
48664955 cGridBag scenePanel;
48674956 cGridBag centralPanel;
....@@ -4976,7 +5065,7 @@
49765065 cNumberSlider fogField;
49775066 JLabel opacityPowerLabel;
49785067 cNumberSlider opacityPowerField;
4979
- JTree jTree;
5068
+ cTree jTree;
49805069 //ObjectUI parent;
49815070
49825071 cNumberSlider normalpushField;