Normand Briere
2019-06-24 914255f70cf047897212839cbf3a6722703f4457
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,52 @@
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
+ cCheckBox GetCheckBox(String name, boolean border)
56
+ {
57
+ try
58
+ {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cCheckBox(icon, border);
61
+ }
62
+ catch (Exception e)
63
+ {
64
+ return new cCheckBox(name, border);
65
+ }
66
+ }
67
+
68
+ private ImageIcon GetIcon(String name) throws IOException
69
+ {
70
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
71
+
72
+ if (image.getWidth() != 24 && image.getHeight() != 24)
73
+ {
74
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
75
+ Graphics2D g = resized.createGraphics();
76
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
77
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
78
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
79
+ g.dispose();
80
+
81
+ image = resized;
82
+ }
83
+
84
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
85
+ return icon;
86
+ }
4087
4188 // SCRIPT
4289
....@@ -3408,6 +3455,8 @@
34083455
34093456 public void Save()
34103457 {
3458
+ System.err.println("Save");
3459
+
34113460 cRadio tab = GetCurrentTab();
34123461
34133462 boolean temp = CameraPane.SWITCH;
....@@ -3492,6 +3541,8 @@
34923541
34933542 public void Undo()
34943543 {
3544
+ System.err.println("Undo");
3545
+
34953546 cRadio tab = GetCurrentTab();
34963547
34973548 if (tab.undoindex == 0)
....@@ -4170,7 +4221,8 @@
41704221
41714222 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41724223 {
4173
- Save();
4224
+ if (Globals.SAVEONMAKE)
4225
+ Save();
41744226 //Tween.set(thing, 0).target(1).start(tweenManager);
41754227 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41764228 // if (thing instanceof GenericJointDemo)
....@@ -4479,6 +4531,7 @@
44794531
44804532 if (readobj != null)
44814533 {
4534
+ if (Globals.SAVEONMAKE)
44824535 Save();
44834536 try
44844537 {