10
10
import java .util .ArrayList ;
11
11
import java .util .Arrays ;
12
12
13
+ import ModernDocking .app .AppState ;
13
14
import ModernDocking .app .Docking ;
14
15
import ModernDocking .app .RootDockingPanel ;
16
+ import ModernDocking .exception .DockingLayoutException ;
15
17
import ModernDocking .ext .ui .DockingUI ;
16
18
import com .formdev .flatlaf .FlatLaf ;
17
19
import com .formdev .flatlaf .FlatLightLaf ;
18
- import com .marginallyclever .weavingradon .core .MulticolorThreader ;
19
- import com .marginallyclever .weavingradon .core .Loom ;
20
- import com .marginallyclever .weavingradon .core .RenderHintHelper ;
21
- import com .marginallyclever .weavingradon .core .MonochromaticThreader ;
20
+ import com .marginallyclever .weavingradon .core .*;
22
21
import com .marginallyclever .weavingradon .ui .*;
23
22
24
23
public class WeavingApp {
25
24
public static final int DIAMETER = 800 ;
25
+ public static final int NUM_NAILS = 188 ;
26
26
public static final int TITLEBAR_HEIGHT = 30 ;
27
27
public static final int DOCKING_TAB_HEIGHT = 30 ;
28
- public static final int ALPHA = 127 ;
28
+ public static final int ALPHA = 64 ;
29
29
public static final int TOOLBAR_HEIGHT = 30 ;
30
30
31
31
private final JFrame frame ;
32
32
private final ArrayList <DockingPanel > windows = new ArrayList <>();
33
33
private final JFileChooser fileChooser ;
34
34
35
- private final Loom loom = new Loom (DIAMETER /2 , 100 );
35
+ private final Loom loom = new Loom (DIAMETER /2 , NUM_NAILS );
36
36
private final LoomPanel loomPanel ;
37
37
private final RadonPanel radonPanel ;
38
38
39
- //public final RadonThreader myThreader = new SingleThreader(Color.WHITE) ;
40
- public final MulticolorThreader myThreader = new MulticolorThreader ();
41
- public final MonochromaticThreader radonThreaderC = new MonochromaticThreader (new Color ( 0 ,255 ,255 , ALPHA ));
42
- public final MonochromaticThreader radonThreaderM = new MonochromaticThreader (new Color (255 , 0 ,255 , ALPHA ));
43
- public final MonochromaticThreader radonThreaderY = new MonochromaticThreader (new Color (255 ,255 , 0 , ALPHA ));
44
- public final MonochromaticThreader radonThreaderK = new MonochromaticThreader (new Color ( 0 , 0 , 0 , ALPHA ));
45
- public final MonochromaticThreader radonThreaderW = new MonochromaticThreader (new Color (255 ,255 ,255 , ALPHA ));
39
+ private final RadonThreader myThreader ;
40
+ /*
41
+ private final MonochromaticThreader radonThreaderC = new MonochromaticThreader(new Color( 0,255,255, ALPHA));
42
+ private final MonochromaticThreader radonThreaderM = new MonochromaticThreader(new Color(255, 0,255, ALPHA));
43
+ private final MonochromaticThreader radonThreaderY = new MonochromaticThreader(new Color(255,255, 0, ALPHA));
44
+ private final MonochromaticThreader radonThreaderK = new MonochromaticThreader(new Color( 0, 0, 0, ALPHA));
45
+ private final MonochromaticThreader radonThreaderW = new MonochromaticThreader(new Color(255,255,255, ALPHA));*/
46
46
47
47
private final OneLineOnImage singleLine ;
48
48
private final RadonPanel singleRadon ;
49
- public final MonochromaticThreader radonThreaderB = new MonochromaticThreader (new Color (255 ,255 ,255 ));
49
+ private final MonochromaticThreader radonThreaderB = new MonochromaticThreader (new Color (255 ,255 ,255 ));
50
50
51
51
public static void main (String [] args ) {
52
52
SwingUtilities .invokeLater (WeavingApp ::new );
@@ -61,6 +61,23 @@ public WeavingApp() {
61
61
//frame.setLocationByPlatform(true);
62
62
frame .setLocationRelativeTo (null );
63
63
64
+ myThreader = new MonochromaticThreader (new Color (255 ,255 ,255 , ALPHA ));
65
+ /*
66
+ MulticolorThreader mct = new MulticolorThreader();
67
+ mct.addColor(new Color( 0,255,255, ALPHA));
68
+ mct.addColor(new Color(255, 0,255, ALPHA));
69
+ mct.addColor(new Color(255,255, 0, ALPHA));
70
+ mct.addColor(new Color( 0, 0, 0, ALPHA));
71
+ mct.addColor(new Color(255,255,255, ALPHA));
72
+ myThreader = mct;
73
+ */
74
+ /*
75
+ mct.addThreader(radonThreaderC);
76
+ mct.addThreader(radonThreaderM);
77
+ mct.addThreader(radonThreaderY);
78
+ mct.addThreader(radonThreaderK);
79
+ mct.addThreader(radonThreaderW);
80
+ */
64
81
// create panels
65
82
loomPanel = new LoomPanel ();
66
83
radonPanel = new RadonPanel (loomPanel );
@@ -70,16 +87,11 @@ public WeavingApp() {
70
87
singleRadon = new RadonPanel (singleLine );
71
88
singleLine .setRadon (radonThreaderB ,singleRadon );
72
89
73
- myThreader .addThreader (radonThreaderC );
74
- myThreader .addThreader (radonThreaderM );
75
- myThreader .addThreader (radonThreaderY );
76
- myThreader .addThreader (radonThreaderK );
77
- myThreader .addThreader (radonThreaderW );
78
-
79
90
// setup the docking system and dock the panels.
80
91
initDocking ();
81
92
createDefaultLayout ();
82
93
resetDefaultLayout ();
94
+ saveAndRestoreLayout ();
83
95
frame .setJMenuBar (new MainMenu (this ));
84
96
85
97
// create a file chooser for images
@@ -152,6 +164,19 @@ private void resetDefaultLayout() {
152
164
//Docking.dock(windows.get(1), windows.get(3), DockingRegion.CENTER);
153
165
}
154
166
167
+ private void saveAndRestoreLayout () {
168
+ // now that the main frame is set up with the defaults, we can restore the layout
169
+ AppState .setPersistFile (new File ("app.layout" ));
170
+ AppState .setAutoPersist (true );
171
+
172
+ try {
173
+ AppState .restore ();
174
+ } catch (DockingLayoutException e ) {
175
+ // something happened trying to load the layout file, record it here
176
+ e .printStackTrace ();
177
+ }
178
+ }
179
+
155
180
public void openFile (ActionEvent actionEvent ) {
156
181
// show the file chooser dialog
157
182
if (fileChooser .showOpenDialog (frame )== JFileChooser . APPROVE_OPTION ) {
@@ -163,7 +188,7 @@ public void openFile(ActionEvent actionEvent) {
163
188
loom .reset ();
164
189
// build a radon transform for every thread, based on the color filter for that threader.
165
190
myThreader .setLoomAndImage (loom ,square );
166
- myThreader .maskCurrentRadonByAllThreads ();
191
+ myThreader .maskRadonTransformByAllThreads ();
167
192
168
193
loomPanel .setLoomAndImage (loom ,square );
169
194
radonPanel .setRadonTransform (myThreader .getRadonTransform ());
0 commit comments