Lines 17-22
Link Here
|
17 |
import java.awt.Color; |
17 |
import java.awt.Color; |
18 |
import java.awt.Component; |
18 |
import java.awt.Component; |
19 |
import java.awt.Dimension; |
19 |
import java.awt.Dimension; |
|
|
20 |
import java.awt.Font; |
20 |
import java.awt.Graphics; |
21 |
import java.awt.Graphics; |
21 |
import java.awt.Image; |
22 |
import java.awt.Image; |
22 |
import java.awt.Toolkit; |
23 |
import java.awt.Toolkit; |
Lines 32-46
Link Here
|
32 |
import java.util.HashSet; |
33 |
import java.util.HashSet; |
33 |
import java.util.Iterator; |
34 |
import java.util.Iterator; |
34 |
import java.util.Set; |
35 |
import java.util.Set; |
|
|
36 |
import java.util.Observable; |
37 |
import java.util.Observer; |
35 |
import javax.swing.Action; |
38 |
import javax.swing.Action; |
|
|
39 |
import javax.swing.ButtonGroup; |
36 |
import javax.swing.Icon; |
40 |
import javax.swing.Icon; |
37 |
import javax.swing.ImageIcon; |
41 |
import javax.swing.ImageIcon; |
38 |
import javax.swing.JButton; |
42 |
import javax.swing.JButton; |
|
|
43 |
import javax.swing.JColorChooser; |
44 |
import javax.swing.JFormattedTextField; |
39 |
import javax.swing.JLabel; |
45 |
import javax.swing.JLabel; |
|
|
46 |
import javax.swing.JOptionPane; |
40 |
import javax.swing.JPanel; |
47 |
import javax.swing.JPanel; |
41 |
import javax.swing.JScrollPane; |
48 |
import javax.swing.JScrollPane; |
|
|
49 |
import javax.swing.JSpinner; |
50 |
import javax.swing.JTextField; |
42 |
import javax.swing.JToggleButton; |
51 |
import javax.swing.JToggleButton; |
43 |
import javax.swing.JToolBar; |
52 |
import javax.swing.JToolBar; |
|
|
53 |
import javax.swing.SpinnerModel; |
54 |
import javax.swing.SpinnerNumberModel; |
44 |
|
55 |
|
45 |
import org.openide.filesystems.FileObject; |
56 |
import org.openide.filesystems.FileObject; |
46 |
import org.openide.filesystems.FileUtil; |
57 |
import org.openide.filesystems.FileUtil; |
Lines 60-66
Link Here
|
60 |
* @author Petr Hamernik, Ian Formanek, Lukas Tadial |
71 |
* @author Petr Hamernik, Ian Formanek, Lukas Tadial |
61 |
* @author Marian Petras |
72 |
* @author Marian Petras |
62 |
*/ |
73 |
*/ |
63 |
public class ImageViewer extends CloneableTopComponent { |
74 |
public class ImageViewer extends CloneableTopComponent implements Observer { |
64 |
|
75 |
|
65 |
/** Serialized version UID. */ |
76 |
/** Serialized version UID. */ |
66 |
static final long serialVersionUID =6960127954234034486L; |
77 |
static final long serialVersionUID =6960127954234034486L; |
Lines 72-91
Link Here
|
72 |
private NBImageIcon storedImage; |
83 |
private NBImageIcon storedImage; |
73 |
|
84 |
|
74 |
/** Component showing image. */ |
85 |
/** Component showing image. */ |
75 |
private JPanel panel; |
86 |
private ImageDisplayEdit panel; |
76 |
|
87 |
|
77 |
/** Scale of image. */ |
88 |
/** Scale of image. */ |
78 |
private double scale = 1.0D; |
89 |
private double scale = 1.0D; |
79 |
|
90 |
|
80 |
/** On/off grid. */ |
|
|
81 |
private boolean showGrid = false; |
82 |
|
83 |
/** Increase/decrease factor. */ |
91 |
/** Increase/decrease factor. */ |
84 |
private final double changeFactor = Math.sqrt(2.0D); |
92 |
private final double changeFactor = Math.sqrt(2.0D); |
85 |
|
93 |
|
86 |
/** Grid color. */ |
|
|
87 |
private final Color gridColor = Color.black; |
88 |
|
89 |
/** Listens for name changes. */ |
94 |
/** Listens for name changes. */ |
90 |
private PropertyChangeListener nameChangeL; |
95 |
private PropertyChangeListener nameChangeL; |
91 |
|
96 |
|
Lines 93-98
Link Here
|
93 |
private final Collection/*<JButton>*/ toolbarButtons |
98 |
private final Collection/*<JButton>*/ toolbarButtons |
94 |
= new ArrayList/*<JButton>*/(11); |
99 |
= new ArrayList/*<JButton>*/(11); |
95 |
|
100 |
|
|
|
101 |
/** The tool selected */ |
102 |
private int Tool = 1; |
103 |
|
104 |
/** The line width selection */ |
105 |
private int lineWidth = 1; |
106 |
|
107 |
/** The fill type selection for rectangle and ellipse tools */ |
108 |
private int fillType = 1; |
109 |
|
110 |
private JToggleButton oneptLine; |
111 |
private JToggleButton threeptLine; |
112 |
private JToggleButton sixptLine; |
113 |
|
114 |
private JToggleButton noFillRect; |
115 |
private JToggleButton fillRect; |
116 |
private JToggleButton noLineRect; |
117 |
|
118 |
private JToggleButton noFillEllipse; |
119 |
private JToggleButton fillEllipse; |
120 |
private JToggleButton noLineEllipse; |
121 |
|
122 |
private JSpinner cornerRounding; |
123 |
|
124 |
private JColorChooser fgColor = new JColorChooser(); |
125 |
private JColorChooser bgColor = new JColorChooser(); |
96 |
|
126 |
|
97 |
/** Default constructor. Must be here, used during de-externalization */ |
127 |
/** Default constructor. Must be here, used during de-externalization */ |
98 |
public ImageViewer () { |
128 |
public ImageViewer () { |
Lines 124-129
Link Here
|
124 |
|
154 |
|
125 |
storedObject = obj; |
155 |
storedObject = obj; |
126 |
|
156 |
|
|
|
157 |
/* Add an observer */ |
158 |
storedObject.addObserver(this); |
159 |
|
127 |
// force closing panes in all workspaces, default is in current only |
160 |
// force closing panes in all workspaces, default is in current only |
128 |
setCloseOperation(TopComponent.CLOSE_EACH); |
161 |
setCloseOperation(TopComponent.CLOSE_EACH); |
129 |
|
162 |
|
Lines 132-137
Link Here
|
132 |
|
165 |
|
133 |
/* compose the whole panel: */ |
166 |
/* compose the whole panel: */ |
134 |
JToolBar toolbar = createToolBar(); |
167 |
JToolBar toolbar = createToolBar(); |
|
|
168 |
JToolBar edittoolbar = createEditToolBar(); |
135 |
Component view; |
169 |
Component view; |
136 |
if (storedImage != null) { |
170 |
if (storedImage != null) { |
137 |
view = createImageView(); |
171 |
view = createImageView(); |
Lines 142-147
Link Here
|
142 |
setLayout(new BorderLayout()); |
176 |
setLayout(new BorderLayout()); |
143 |
add(view, BorderLayout.CENTER); |
177 |
add(view, BorderLayout.CENTER); |
144 |
add(toolbar, BorderLayout.NORTH); |
178 |
add(toolbar, BorderLayout.NORTH); |
|
|
179 |
add(edittoolbar, BorderLayout.WEST); |
145 |
|
180 |
|
146 |
getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ImageViewer.class).getString("ACS_ImageViewer")); |
181 |
getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ImageViewer.class).getString("ACS_ImageViewer")); |
147 |
|
182 |
|
Lines 160-207
Link Here
|
160 |
/** |
195 |
/** |
161 |
*/ |
196 |
*/ |
162 |
private Component createImageView() { |
197 |
private Component createImageView() { |
163 |
panel = new JPanel() { |
198 |
panel = new ImageDisplayEdit(storedImage, getScale()); |
164 |
protected void paintComponent(Graphics g) { |
|
|
165 |
super.paintComponent(g); |
166 |
g.drawImage( |
167 |
storedImage.getImage(), |
168 |
0, |
169 |
0, |
170 |
(int)(getScale () * storedImage.getIconWidth ()), |
171 |
(int)(getScale () * storedImage.getIconHeight ()), |
172 |
0, |
173 |
0, |
174 |
storedImage.getIconWidth(), |
175 |
storedImage.getIconHeight(), |
176 |
this |
177 |
); |
178 |
|
179 |
if(showGrid) { |
180 |
int x = (int)(getScale () * storedImage.getIconWidth ()); |
181 |
int y = (int)(getScale () * storedImage.getIconHeight ()); |
182 |
|
183 |
double gridDistance = getScale(); |
184 |
|
185 |
if(gridDistance < 2) |
186 |
// Disable painting of grid if no image pixels would be visible. |
187 |
return; |
188 |
|
189 |
g.setColor(gridColor); |
190 |
|
191 |
double actualDistance = gridDistance; |
192 |
for(int i = (int)actualDistance; i < x ;actualDistance += gridDistance, i = (int)actualDistance) { |
193 |
g.drawLine(i,0,i,(y-1)); |
194 |
} |
195 |
|
196 |
actualDistance = gridDistance; |
197 |
for(int j = (int)actualDistance; j < y; actualDistance += gridDistance, j = (int)actualDistance) { |
198 |
g.drawLine(0,j,(x-1),j); |
199 |
} |
200 |
} |
201 |
|
202 |
} |
203 |
|
204 |
}; |
205 |
storedImage.setImageObserver(panel); |
199 |
storedImage.setImageObserver(panel); |
206 |
panel.setPreferredSize(new Dimension(storedImage.getIconWidth(), storedImage.getIconHeight() )); |
200 |
panel.setPreferredSize(new Dimension(storedImage.getIconWidth(), storedImage.getIconHeight() )); |
207 |
JScrollPane scroll = new JScrollPane(panel); |
201 |
JScrollPane scroll = new JScrollPane(panel); |
Lines 344-353
Link Here
|
344 |
toolBar.addSeparator(new Dimension(11,2)); |
338 |
toolBar.addSeparator(new Dimension(11,2)); |
345 |
toolBar.add(button = getGridButton()); |
339 |
toolBar.add(button = getGridButton()); |
346 |
toolbarButtons.add(button); |
340 |
toolbarButtons.add(button); |
|
|
341 |
toolBar.addSeparator(new Dimension(11,2)); |
342 |
toolBar.add(button = getConvertButton()); |
343 |
toolbarButtons.add(button); |
344 |
|
347 |
|
345 |
|
348 |
return toolBar; |
346 |
return toolBar; |
349 |
} |
347 |
} |
350 |
|
348 |
|
|
|
349 |
//** Creates edittoolbar. */ |
350 |
private JToolBar createEditToolBar() |
351 |
{ |
352 |
/* |
353 |
BTN_Select=1 |
354 |
BTN_Polygon=2 |
355 |
BTN_Pen=3 |
356 |
BTN_Brush=4 |
357 |
BTN_Arc=5 |
358 |
BTN_Line=6 |
359 |
BTN_Rectangle=7 |
360 |
BTN_Ellipse=8 |
361 |
BTN_Fill=9 |
362 |
BTN_Spray=10 |
363 |
*/ |
364 |
|
365 |
ButtonGroup bgGroup = new javax.swing.ButtonGroup(); |
366 |
ButtonGroup bgLineWidth = new javax.swing.ButtonGroup(); |
367 |
ButtonGroup bgRect = new javax.swing.ButtonGroup(); |
368 |
ButtonGroup bgEllipse = new javax.swing.ButtonGroup(); |
369 |
JToolBar editToolBar = new javax.swing.JToolBar(); |
370 |
editToolBar.setName (NbBundle.getBundle(ImageViewer.class).getString("ACSN_EditToolbar")); |
371 |
editToolBar.setOrientation(1); |
372 |
|
373 |
setLayout(null); |
374 |
|
375 |
editToolBar.setFloatable (false); |
376 |
|
377 |
JToggleButton selectTButton = new JToggleButton(); |
378 |
editToolBar.add(selectTButton = getSelectTButton()); |
379 |
selectTButton.setSelected(true); |
380 |
bgGroup.add(selectTButton); |
381 |
|
382 |
JToggleButton polygonTButton = new JToggleButton(); |
383 |
editToolBar.add(polygonTButton = getPolygonTButton()); |
384 |
bgGroup.add(polygonTButton); |
385 |
|
386 |
JToggleButton penTButton = new JToggleButton(); |
387 |
editToolBar.add(penTButton = getPenTButton()); |
388 |
bgGroup.add(penTButton); |
389 |
|
390 |
JToggleButton brushTButton = new JToggleButton(); |
391 |
editToolBar.add(brushTButton = getBrushTButton()); |
392 |
bgGroup.add(brushTButton); |
393 |
|
394 |
JToggleButton arcTButton = new JToggleButton(); |
395 |
editToolBar.add(arcTButton = getArcTButton()); |
396 |
bgGroup.add(arcTButton); |
397 |
|
398 |
JToggleButton lineTButton = new JToggleButton(); |
399 |
editToolBar.add(lineTButton = getLineTButton()); |
400 |
bgGroup.add(lineTButton); |
401 |
|
402 |
JToggleButton rectangleTButton = new JToggleButton(); |
403 |
editToolBar.add(rectangleTButton = getRectangleTButton()); |
404 |
bgGroup.add(rectangleTButton); |
405 |
|
406 |
JToggleButton ovalTButton = new JToggleButton(); |
407 |
editToolBar.add(ovalTButton = getEllipseTButton()); |
408 |
bgGroup.add(ovalTButton); |
409 |
|
410 |
JToggleButton fillTButton = new JToggleButton(); |
411 |
editToolBar.add(fillTButton = getFillTButton()); |
412 |
bgGroup.add(fillTButton); |
413 |
|
414 |
JToggleButton sprayTButton = new JToggleButton(); |
415 |
editToolBar.add(sprayTButton = getSprayTButton()); |
416 |
bgGroup.add(sprayTButton); |
417 |
|
418 |
JButton foregroundButton = new JButton(); |
419 |
editToolBar.add(foregroundButton = getForegroundButton()); |
420 |
|
421 |
editToolBar.addSeparator(new Dimension(2,2)); |
422 |
|
423 |
JButton backgroundButton = new JButton(); |
424 |
editToolBar.add(backgroundButton = getBackgroundButton()); |
425 |
|
426 |
editToolBar.addSeparator(new Dimension(2,10)); |
427 |
|
428 |
oneptLine = new JToggleButton(); |
429 |
editToolBar.add(oneptLine = getOneptLineTButton()); |
430 |
bgLineWidth.add(oneptLine); |
431 |
oneptLine.setSelected(true); |
432 |
oneptLine.setVisible(false); |
433 |
|
434 |
threeptLine = new JToggleButton(); |
435 |
editToolBar.add(threeptLine = getThreeptLineTButton()); |
436 |
bgLineWidth.add(threeptLine); |
437 |
threeptLine.setVisible(false); |
438 |
|
439 |
sixptLine = new JToggleButton(); |
440 |
editToolBar.add(sixptLine = getSixptLineTButton()); |
441 |
bgLineWidth.add(sixptLine); |
442 |
sixptLine.setVisible(false); |
443 |
|
444 |
editToolBar.addSeparator(new Dimension(2,6)); |
445 |
|
446 |
noFillRect = new JToggleButton(); |
447 |
editToolBar.add(noFillRect = getNoFillRectTButton()); |
448 |
bgRect.add(noFillRect); |
449 |
noFillRect.setSelected(true); |
450 |
noFillRect.setVisible(false); |
451 |
|
452 |
fillRect = new JToggleButton(); |
453 |
editToolBar.add(fillRect = getFillRectTButton()); |
454 |
bgRect.add(fillRect); |
455 |
fillRect.setVisible(false); |
456 |
|
457 |
noLineRect = new JToggleButton(); |
458 |
editToolBar.add(noLineRect = getNoLineRectTButton()); |
459 |
bgRect.add(noLineRect); |
460 |
noLineRect.setVisible(false); |
461 |
|
462 |
editToolBar.addSeparator(new Dimension(2,6)); |
463 |
|
464 |
noFillEllipse = new JToggleButton(); |
465 |
editToolBar.add(noFillEllipse = getNoFillEllipseTButton()); |
466 |
bgEllipse.add(noFillEllipse); |
467 |
noFillEllipse.setSelected(true); |
468 |
noFillEllipse.setVisible(false); |
469 |
|
470 |
fillEllipse = new JToggleButton(); |
471 |
editToolBar.add(fillEllipse = getFillEllipseTButton()); |
472 |
bgEllipse.add(fillEllipse); |
473 |
fillEllipse.setVisible(false); |
474 |
|
475 |
noLineEllipse = new JToggleButton(); |
476 |
editToolBar.add(noLineEllipse = getNoLineEllipseTButton()); |
477 |
bgEllipse.add(noLineEllipse); |
478 |
noLineEllipse.setVisible(false); |
479 |
|
480 |
editToolBar.addSeparator(new Dimension(2,6)); |
481 |
|
482 |
JPanel textPanel = new JPanel(); |
483 |
textPanel.setLayout(null); |
484 |
SpinnerModel cornerRoundingModel = new SpinnerNumberModel(0, 0, 100, 5); |
485 |
cornerRounding = new JSpinner(cornerRoundingModel); |
486 |
cornerRounding.setSize(32,17); |
487 |
|
488 |
JFormattedTextField tf = ((JSpinner.DefaultEditor)cornerRounding.getEditor()).getTextField(); |
489 |
tf.setEditable(false); |
490 |
tf.setFont(new Font("Arial Narrow", 0, 10)); |
491 |
tf.setBackground(Color.white); |
492 |
|
493 |
cornerRounding.setVisible(false); |
494 |
|
495 |
textPanel.add(cornerRounding); |
496 |
editToolBar.add(textPanel); |
497 |
|
498 |
add(editToolBar); |
499 |
|
500 |
return editToolBar; |
501 |
} |
502 |
|
351 |
/** Updates the name and tooltip of this top component according to associated data object. */ |
503 |
/** Updates the name and tooltip of this top component according to associated data object. */ |
352 |
private void updateName () { |
504 |
private void updateName () { |
353 |
// update name |
505 |
// update name |
Lines 541-546
Link Here
|
541 |
SystemAction.get(ZoomInAction.class), |
693 |
SystemAction.get(ZoomInAction.class), |
542 |
SystemAction.get(ZoomOutAction.class), |
694 |
SystemAction.get(ZoomOutAction.class), |
543 |
SystemAction.get(CustomZoomAction.class), |
695 |
SystemAction.get(CustomZoomAction.class), |
|
|
696 |
SystemAction.get(ConvertToAction.class), |
544 |
null}, |
697 |
null}, |
545 |
oldValue); |
698 |
oldValue); |
546 |
} |
699 |
} |
Lines 609-614
Link Here
|
609 |
|
762 |
|
610 |
resizePanel(); |
763 |
resizePanel(); |
611 |
panel.repaint(0, 0, panel.getWidth(), panel.getHeight()); |
764 |
panel.repaint(0, 0, panel.getWidth(), panel.getHeight()); |
|
|
765 |
panel.setScale(scale); |
612 |
} |
766 |
} |
613 |
|
767 |
|
614 |
/** Return zooming factor.*/ |
768 |
/** Return zooming factor.*/ |
Lines 619-624
Link Here
|
619 |
/** Change proportion "out"*/ |
773 |
/** Change proportion "out"*/ |
620 |
private void scaleOut() { |
774 |
private void scaleOut() { |
621 |
scale = scale / changeFactor; |
775 |
scale = scale / changeFactor; |
|
|
776 |
panel.setScale(scale); |
622 |
} |
777 |
} |
623 |
|
778 |
|
624 |
/** Change proportion "in"*/ |
779 |
/** Change proportion "in"*/ |
Lines 632-637
Link Here
|
632 |
if (newComputedScale == oldComputedScale) |
787 |
if (newComputedScale == oldComputedScale) |
633 |
// Has to increase. |
788 |
// Has to increase. |
634 |
scale = newComputedScale + 1.0D; |
789 |
scale = newComputedScale + 1.0D; |
|
|
790 |
|
791 |
panel.setScale(scale); |
792 |
} |
793 |
|
794 |
public void convertTo() { |
795 |
try { |
796 |
storedObject.convertTo(this); |
797 |
} catch(IOException e) { |
798 |
JOptionPane.showMessageDialog(null, NbBundle.getMessage(ImageViewer.class, "MSG_CouldNotConvert"), NbBundle.getMessage(ImageViewer.class, "LBL_CouldNotConvert"), JOptionPane.ERROR_MESSAGE); |
799 |
} |
800 |
} |
801 |
|
802 |
public void update(Observable o, Object arg){ |
803 |
updateView(storedObject); |
804 |
panel.reload(storedImage); |
635 |
} |
805 |
} |
636 |
|
806 |
|
637 |
/** Gets zoom button. */ |
807 |
/** Gets zoom button. */ |
Lines 676-687
Link Here
|
676 |
button.setMnemonic(NbBundle.getBundle(ImageViewer.class).getString("ACS_Grid_BTN_Mnem").charAt(0)); |
846 |
button.setMnemonic(NbBundle.getBundle(ImageViewer.class).getString("ACS_Grid_BTN_Mnem").charAt(0)); |
677 |
button.addActionListener(new ActionListener() { |
847 |
button.addActionListener(new ActionListener() { |
678 |
public void actionPerformed(ActionEvent evt) { |
848 |
public void actionPerformed(ActionEvent evt) { |
679 |
showGrid = !showGrid; |
849 |
panel.toggleGrid(); |
680 |
panel.repaint(0, 0, panel.getWidth(), panel.getHeight()); |
850 |
panel.repaint(0, 0, panel.getWidth(), panel.getHeight()); |
681 |
} |
851 |
} |
682 |
}); |
852 |
}); |
683 |
|
853 |
|
684 |
return button; |
854 |
return button; |
|
|
855 |
} |
856 |
|
857 |
private JButton getConvertButton() { |
858 |
// PENDING buttons should have their own icons. |
859 |
JButton button = new JButton(NbBundle.getMessage(CustomZoomAction.class, "LBL_ConvertTo")); |
860 |
button.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ImageViewer.class).getString("ACS_Convert_BTN")); |
861 |
button.addActionListener(new ActionListener() { |
862 |
public void actionPerformed(ActionEvent evt) { |
863 |
ConvertToAction sa = (ConvertToAction) SystemAction.get(ConvertToAction.class); |
864 |
sa.performAction(); |
865 |
} |
866 |
}); |
867 |
|
868 |
return button; |
869 |
} |
870 |
|
871 |
/** Gets ellipse button.*/ |
872 |
private JToggleButton getEllipseTButton() { |
873 |
JToggleButton ellipseTButton = new JToggleButton(); |
874 |
ellipseTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Ellipse")); |
875 |
ellipseTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/oval.gif"))); |
876 |
ellipseTButton.setLabel(""); |
877 |
|
878 |
ellipseTButton.addActionListener(new ActionListener() { |
879 |
public void actionPerformed(ActionEvent evt) { |
880 |
setTool(8); |
881 |
setSubtoolsVisible(); |
882 |
} |
883 |
}); |
884 |
|
885 |
return ellipseTButton; |
886 |
} |
887 |
|
888 |
/** Gets rectangle button.*/ |
889 |
private JToggleButton getRectangleTButton(){ |
890 |
JToggleButton rectangleTButton = new JToggleButton(); |
891 |
rectangleTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Rectangle")); |
892 |
rectangleTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/rect.gif"))); |
893 |
rectangleTButton.setLabel(""); |
894 |
|
895 |
rectangleTButton.addActionListener(new ActionListener() { |
896 |
public void actionPerformed(ActionEvent evt) { |
897 |
setTool(7); |
898 |
setSubtoolsVisible(); |
899 |
} |
900 |
}); |
901 |
|
902 |
return rectangleTButton; |
903 |
} |
904 |
|
905 |
/** Gets fill button.*/ |
906 |
private JToggleButton getFillTButton(){ |
907 |
JToggleButton fillTButton = new JToggleButton(); |
908 |
fillTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Fill")); |
909 |
fillTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/fill.gif"))); |
910 |
fillTButton.setLabel(""); |
911 |
|
912 |
fillTButton.addActionListener(new ActionListener() { |
913 |
public void actionPerformed(ActionEvent evt) { |
914 |
setTool(9); |
915 |
setSubtoolsVisible(); |
916 |
} |
917 |
}); |
918 |
|
919 |
return fillTButton; |
920 |
} |
921 |
|
922 |
/** Gets line button.*/ |
923 |
private JToggleButton getLineTButton(){ |
924 |
JToggleButton lineTButton = new JToggleButton(); |
925 |
lineTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Line")); |
926 |
lineTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/line.gif"))); |
927 |
lineTButton.setLabel(""); |
928 |
lineTButton.addActionListener(new ActionListener() { |
929 |
public void actionPerformed(ActionEvent evt) { |
930 |
setTool(6); |
931 |
setSubtoolsVisible(); |
932 |
} |
933 |
}); |
934 |
|
935 |
return lineTButton; |
936 |
} |
937 |
|
938 |
/** Gets select button.*/ |
939 |
private JToggleButton getSelectTButton(){ |
940 |
JToggleButton selectTButton = new JToggleButton(); |
941 |
selectTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Select")); |
942 |
selectTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/arrow.gif"))); |
943 |
selectTButton.setLabel(""); |
944 |
|
945 |
selectTButton.addActionListener(new ActionListener() { |
946 |
public void actionPerformed(ActionEvent evt) { |
947 |
setTool(1); |
948 |
setSubtoolsVisible(); |
949 |
} |
950 |
}); |
951 |
|
952 |
return selectTButton; |
953 |
} |
954 |
|
955 |
/** Gets polygon button.*/ |
956 |
private JToggleButton getPolygonTButton(){ |
957 |
JToggleButton polygonTButton = new JToggleButton(); |
958 |
polygonTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Polygon")); |
959 |
polygonTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/polygon.gif"))); |
960 |
polygonTButton.setLabel(""); |
961 |
|
962 |
polygonTButton.addActionListener(new ActionListener() { |
963 |
public void actionPerformed(ActionEvent evt) { |
964 |
setTool(2); |
965 |
setSubtoolsVisible(); |
966 |
} |
967 |
}); |
968 |
|
969 |
return polygonTButton; |
970 |
} |
971 |
|
972 |
/** Gets pen button.*/ |
973 |
private JToggleButton getPenTButton(){ |
974 |
JToggleButton penTButton = new JToggleButton(); |
975 |
penTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Pen")); |
976 |
penTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/pen.gif"))); |
977 |
penTButton.setLabel(""); |
978 |
|
979 |
penTButton.addActionListener(new ActionListener() { |
980 |
public void actionPerformed(ActionEvent evt) { |
981 |
setTool(3); |
982 |
setSubtoolsVisible(); |
983 |
} |
984 |
}); |
985 |
|
986 |
return penTButton; |
987 |
} |
988 |
|
989 |
/** Gets brush button.*/ |
990 |
private JToggleButton getBrushTButton(){ |
991 |
JToggleButton brushTButton = new JToggleButton(); |
992 |
brushTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Brush")); |
993 |
brushTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/brush.gif"))); |
994 |
brushTButton.setLabel(""); |
995 |
|
996 |
brushTButton.addActionListener(new ActionListener() { |
997 |
public void actionPerformed(ActionEvent evt) { |
998 |
setTool(4); |
999 |
setSubtoolsVisible(); |
1000 |
} |
1001 |
}); |
1002 |
|
1003 |
return brushTButton; |
1004 |
} |
1005 |
|
1006 |
/** Gets arc button.*/ |
1007 |
private JToggleButton getArcTButton(){ |
1008 |
JToggleButton arcTButton = new JToggleButton(); |
1009 |
arcTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Arc")); |
1010 |
arcTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/arc.gif"))); |
1011 |
arcTButton.setLabel(""); |
1012 |
|
1013 |
arcTButton.addActionListener(new ActionListener() { |
1014 |
public void actionPerformed(ActionEvent evt) { |
1015 |
setTool(5); |
1016 |
setSubtoolsVisible(); |
1017 |
} |
1018 |
}); |
1019 |
|
1020 |
return arcTButton; |
1021 |
} |
1022 |
|
1023 |
/** Gets spray button.*/ |
1024 |
private JToggleButton getSprayTButton(){ |
1025 |
JToggleButton sprayTButton = new JToggleButton(); |
1026 |
sprayTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Spray")); |
1027 |
sprayTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/spray.gif"))); |
1028 |
sprayTButton.setLabel(""); |
1029 |
|
1030 |
sprayTButton.addActionListener(new ActionListener() { |
1031 |
public void actionPerformed(ActionEvent evt) { |
1032 |
setTool(10); |
1033 |
setSubtoolsVisible(); |
1034 |
} |
1035 |
}); |
1036 |
|
1037 |
return sprayTButton; |
1038 |
} |
1039 |
|
1040 |
/** Gets foreground button.*/ |
1041 |
private JButton getForegroundButton(){ |
1042 |
final JButton foregroundButton = new JButton(" "); |
1043 |
foregroundButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_SetLineColor")); |
1044 |
foregroundButton.setBackground(new Color(0, 0, 0)); |
1045 |
foregroundButton.addActionListener(new ActionListener() |
1046 |
{ |
1047 |
public void actionPerformed(ActionEvent evt) |
1048 |
{ |
1049 |
Color newColor = fgColor.showDialog(null,NbBundle.getMessage(ImageViewer.class, "LBL_ForegroundColor"), foregroundButton.getForeground()); |
1050 |
foregroundButton.setBackground(newColor); |
1051 |
|
1052 |
panel.setPrimaryColor(newColor); |
1053 |
} |
1054 |
}); |
1055 |
|
1056 |
return foregroundButton; |
1057 |
} |
1058 |
|
1059 |
/** Gets background button.*/ |
1060 |
private JButton getBackgroundButton(){ |
1061 |
final JButton backgroundButton = new JButton(" "); |
1062 |
backgroundButton.setBackground(new Color(128, 128, 255)); |
1063 |
backgroundButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_SetFillColor")); |
1064 |
backgroundButton.addActionListener(new ActionListener() |
1065 |
{ |
1066 |
public void actionPerformed(ActionEvent evt) |
1067 |
{ |
1068 |
Color newColor = bgColor.showDialog(null,NbBundle.getMessage(ImageViewer.class, "LBL_BackgroundColor"), backgroundButton.getBackground()); |
1069 |
backgroundButton.setBackground(newColor); |
1070 |
|
1071 |
panel.setSecondayColor(newColor); |
1072 |
} |
1073 |
}); |
1074 |
|
1075 |
return backgroundButton; |
1076 |
} |
1077 |
|
1078 |
/** Gets oneptLine button */ |
1079 |
private JToggleButton getOneptLineTButton(){ |
1080 |
JToggleButton oneptLineTButton = new JToggleButton(); |
1081 |
// oneptLineTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Spray")); |
1082 |
oneptLineTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/1ptLine.gif"))); |
1083 |
oneptLineTButton.setLabel(""); |
1084 |
|
1085 |
oneptLineTButton.addActionListener(new ActionListener() { |
1086 |
public void actionPerformed(ActionEvent evt) { |
1087 |
setLineWidth(1); |
1088 |
} |
1089 |
}); |
1090 |
|
1091 |
return oneptLineTButton; |
1092 |
} |
1093 |
|
1094 |
/** Gets threeptLine button */ |
1095 |
private JToggleButton getThreeptLineTButton(){ |
1096 |
JToggleButton threeptLineTButton = new JToggleButton(); |
1097 |
// threeptLineTButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_Spray")); |
1098 |
threeptLineTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/3ptLine.gif"))); |
1099 |
threeptLineTButton.setLabel(""); |
1100 |
|
1101 |
threeptLineTButton.addActionListener(new ActionListener() { |
1102 |
public void actionPerformed(ActionEvent evt) { |
1103 |
setLineWidth(3); |
1104 |
} |
1105 |
}); |
1106 |
|
1107 |
return threeptLineTButton; |
1108 |
} |
1109 |
|
1110 |
/** Gets sixptLine button */ |
1111 |
private JToggleButton getSixptLineTButton(){ |
1112 |
JToggleButton sixptLineTButton = new JToggleButton(); |
1113 |
sixptLineTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/6ptLine.gif"))); |
1114 |
sixptLineTButton.setLabel(""); |
1115 |
|
1116 |
sixptLineTButton.addActionListener(new ActionListener() { |
1117 |
public void actionPerformed(ActionEvent evt) { |
1118 |
setLineWidth(6); |
1119 |
} |
1120 |
}); |
1121 |
|
1122 |
return sixptLineTButton; |
1123 |
} |
1124 |
|
1125 |
/** Gets noFillRect button */ |
1126 |
private JToggleButton getNoFillRectTButton(){ |
1127 |
JToggleButton noFillRectTButton = new JToggleButton(); |
1128 |
noFillRectTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/noFillRect.gif"))); |
1129 |
noFillRectTButton.setLabel(""); |
1130 |
|
1131 |
noFillRectTButton.addActionListener(new ActionListener() { |
1132 |
public void actionPerformed(ActionEvent evt) { |
1133 |
setFillType(1); |
1134 |
} |
1135 |
}); |
1136 |
|
1137 |
return noFillRectTButton; |
1138 |
} |
1139 |
|
1140 |
/** Gets fillRect button */ |
1141 |
private JToggleButton getFillRectTButton(){ |
1142 |
JToggleButton fillRectTButton = new JToggleButton(); |
1143 |
fillRectTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/fillRect.gif"))); |
1144 |
fillRectTButton.setLabel(""); |
1145 |
|
1146 |
fillRectTButton.addActionListener(new ActionListener() { |
1147 |
public void actionPerformed(ActionEvent evt) { |
1148 |
setFillType(2); |
1149 |
} |
1150 |
}); |
1151 |
|
1152 |
return fillRectTButton; |
1153 |
} |
1154 |
|
1155 |
/** Gets noLineRect button */ |
1156 |
private JToggleButton getNoLineRectTButton(){ |
1157 |
JToggleButton noLineRectTButton = new JToggleButton(); |
1158 |
noLineRectTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/noLineRect.gif"))); |
1159 |
noLineRectTButton.setLabel(""); |
1160 |
|
1161 |
noLineRectTButton.addActionListener(new ActionListener() { |
1162 |
public void actionPerformed(ActionEvent evt) { |
1163 |
setFillType(3); |
1164 |
} |
1165 |
}); |
1166 |
|
1167 |
return noLineRectTButton; |
1168 |
} |
1169 |
|
1170 |
/** Gets noFillEllipse button */ |
1171 |
private JToggleButton getNoFillEllipseTButton(){ |
1172 |
JToggleButton noFillEllipseTButton = new JToggleButton(); |
1173 |
noFillEllipseTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/noFillEllipse.gif"))); |
1174 |
noFillEllipseTButton.setLabel(""); |
1175 |
|
1176 |
noFillEllipseTButton.addActionListener(new ActionListener() { |
1177 |
public void actionPerformed(ActionEvent evt) { |
1178 |
setFillType(1); |
1179 |
} |
1180 |
}); |
1181 |
|
1182 |
return noFillEllipseTButton; |
1183 |
} |
1184 |
|
1185 |
/** Gets fillEllipse button */ |
1186 |
private JToggleButton getFillEllipseTButton(){ |
1187 |
JToggleButton fillEllipseTButton = new JToggleButton(); |
1188 |
fillEllipseTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/fillEllipse.gif"))); |
1189 |
fillEllipseTButton.setLabel(""); |
1190 |
|
1191 |
fillEllipseTButton.addActionListener(new ActionListener() { |
1192 |
public void actionPerformed(ActionEvent evt) { |
1193 |
setFillType(2); |
1194 |
} |
1195 |
}); |
1196 |
|
1197 |
return fillEllipseTButton; |
1198 |
} |
1199 |
|
1200 |
/** Gets noLineEllipse button */ |
1201 |
private JToggleButton getNoLineEllipseTButton(){ |
1202 |
JToggleButton noLineEllipseTButton = new JToggleButton(); |
1203 |
noLineEllipseTButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/image/noLineEllipse.gif"))); |
1204 |
noLineEllipseTButton.setLabel(""); |
1205 |
|
1206 |
noLineEllipseTButton.addActionListener(new ActionListener() { |
1207 |
public void actionPerformed(ActionEvent evt) { |
1208 |
setFillType(3); |
1209 |
} |
1210 |
}); |
1211 |
|
1212 |
return noLineEllipseTButton; |
1213 |
} |
1214 |
|
1215 |
/** set the lines widths visible */ |
1216 |
private void setSubtoolsVisible(){ |
1217 |
switch (getTool()){ |
1218 |
case 2: |
1219 |
case 5: |
1220 |
case 6: |
1221 |
case 7: |
1222 |
case 8: |
1223 |
oneptLine.setVisible(true); |
1224 |
threeptLine.setVisible(true); |
1225 |
sixptLine.setVisible(true); |
1226 |
break; |
1227 |
default: |
1228 |
oneptLine.setVisible(false); |
1229 |
threeptLine.setVisible(false); |
1230 |
sixptLine.setVisible(false); |
1231 |
break; |
1232 |
} |
1233 |
|
1234 |
if (getTool() == 7){ |
1235 |
noFillRect.setVisible(true); |
1236 |
fillRect.setVisible(true); |
1237 |
noLineRect.setVisible(true); |
1238 |
cornerRounding.setVisible(true); |
1239 |
setFillType(1); |
1240 |
noFillRect.setSelected(true); |
1241 |
}else{ |
1242 |
noFillRect.setVisible(false); |
1243 |
fillRect.setVisible(false); |
1244 |
noLineRect.setVisible(false); |
1245 |
cornerRounding.setVisible(false); |
1246 |
} |
1247 |
|
1248 |
if (getTool() == 8){ |
1249 |
noFillEllipse.setVisible(true); |
1250 |
fillEllipse.setVisible(true); |
1251 |
noLineEllipse.setVisible(true); |
1252 |
setFillType(1); |
1253 |
noFillEllipse.setSelected(true); |
1254 |
}else{ |
1255 |
noFillEllipse.setVisible(false); |
1256 |
fillEllipse.setVisible(false); |
1257 |
noLineEllipse.setVisible(false); |
1258 |
} |
1259 |
} |
1260 |
|
1261 |
/** Set the tool. */ |
1262 |
public void setTool(int selection){ |
1263 |
Tool = selection; |
1264 |
} |
1265 |
|
1266 |
/** Get the tool. */ |
1267 |
public int getTool(){ |
1268 |
return Tool; |
1269 |
} |
1270 |
|
1271 |
/** Set the sub tool */ |
1272 |
public void setLineWidth(int selection){ |
1273 |
lineWidth = selection; |
1274 |
} |
1275 |
|
1276 |
/** Get the sub tool */ |
1277 |
public int getLineWidth(){ |
1278 |
return lineWidth; |
1279 |
} |
1280 |
|
1281 |
/** Set the sub tool */ |
1282 |
public void setFillType(int selection){ |
1283 |
fillType = selection; |
1284 |
} |
1285 |
|
1286 |
/** Get the sub tool */ |
1287 |
public int getFillType(){ |
1288 |
return fillType; |
1289 |
} |
1290 |
|
1291 |
public int getCornerRoundingFactor() { |
1292 |
return ((Integer)(cornerRounding.getValue())).intValue(); |
685 |
} |
1293 |
} |
686 |
|
1294 |
|
687 |
} |
1295 |
} |