10 package com.generalrobotix.ui.view.graph;
13 import java.awt.event.*;
40 boolean legendOutput_;
42 JTextField pathField_;
43 JCheckBox colorCheck_;
44 JCheckBox graphCheck_;
45 JCheckBox legendCheck_;
47 JFileChooser chooser_;
59 chooser_ =
new JFileChooser(System.getProperty(
"user.dir"));
62 JLabel outputLabel =
new JLabel(
MessageBundle.
get(
"dialog.graph.eps.outputto"));
63 int labelWidth = outputLabel.getMinimumSize().width;
64 pathField_ =
new JTextField(
"", 20);
65 pathField_.setPreferredSize(
new Dimension(400, 26));
66 pathField_.setMaximumSize(
new Dimension(400, 26));
67 JButton browseButton =
new JButton(
MessageBundle.
get(
"dialog.graph.eps.browse"));
68 browseButton.addActionListener(
69 new ActionListener() {
70 public void actionPerformed(ActionEvent evt) {
73 if (result == JFileChooser.APPROVE_OPTION) {
75 chooser_.getSelectedFile().getPath()
81 JPanel line1 =
new JPanel();
82 line1.setLayout(
new BoxLayout(line1, BoxLayout.X_AXIS));
83 line1.add(Box.createHorizontalStrut(BORDER_GAP));
84 line1.add(outputLabel);
86 line1.add(Box.createHorizontalStrut(LABEL_GAP));
87 line1.add(pathField_);
88 line1.add(Box.createHorizontalStrut(5));
89 line1.add(browseButton);
91 line1.add(Box.createHorizontalStrut(BORDER_GAP));
92 line1.setAlignmentX(Component.LEFT_ALIGNMENT);
95 ItemListener checkListener =
new ItemListener() {
96 public void itemStateChanged(ItemEvent evt) {
98 graphCheck_.isSelected()
99 || legendCheck_.isSelected()
107 graphCheck_.addItemListener(checkListener);
109 legendCheck_.addItemListener(checkListener);
110 JPanel line2 =
new JPanel();
111 line2.setLayout(
new BoxLayout(line2, BoxLayout.X_AXIS));
112 line2.add(Box.createHorizontalStrut(BORDER_GAP));
113 line2.add(Box.createHorizontalStrut(labelWidth));
114 line2.add(Box.createHorizontalStrut(LABEL_GAP));
115 line2.add(colorCheck_);
116 line2.add(Box.createHorizontalStrut(LABEL_GAP));
117 line2.add(graphCheck_);
118 line2.add(Box.createHorizontalStrut(ITEM_GAP));
119 line2.add(legendCheck_);
120 line2.setAlignmentX(Component.LEFT_ALIGNMENT);
124 this.getRootPane().setDefaultButton(okButton_);
125 okButton_.addActionListener(
126 new ActionListener() {
127 public void actionPerformed(ActionEvent evt) {
129 String
path = pathField_.getText().trim();
132 if (!path.equals(
"") && !path.endsWith(
".eps")) {
136 colorOutput_ = colorCheck_.isSelected();
137 graphOutput_ = graphCheck_.isSelected();
138 legendOutput_ = legendCheck_.isSelected();
144 JButton cancelButton =
new JButton(
MessageBundle.
get(
"dialog.cancelButton"));
145 cancelButton.addActionListener(
146 new ActionListener() {
147 public void actionPerformed(ActionEvent evt) {
154 public void keyPressed(KeyEvent evt) {
155 if (evt.getID() == KeyEvent.KEY_PRESSED
156 && evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
162 JPanel bLine =
new JPanel();
163 bLine.setLayout(
new BoxLayout(bLine, BoxLayout.X_AXIS));
164 bLine.add(Box.createHorizontalGlue());
165 bLine.add(okButton_);
166 bLine.add(Box.createHorizontalStrut(BUTTON_GAP));
167 bLine.add(cancelButton);
168 bLine.add(Box.createHorizontalStrut(BORDER_GAP));
169 bLine.setAlignmentX(Component.LEFT_ALIGNMENT);
172 Container pane = getContentPane();
173 pane.setLayout(
new BoxLayout(pane, BoxLayout.Y_AXIS));
174 pane.add(Box.createVerticalStrut(BORDER_GAP));
176 pane.add(Box.createVerticalStrut(ITEM_GAP));
178 pane.add(Box.createVerticalStrut(CONTENTS_GAP));
180 pane.add(Box.createVerticalStrut(BORDER_GAP));
197 pathField_.setText(path_);
198 colorCheck_.setSelected(colorOutput_);
199 graphCheck_.setSelected(graphOutput_);
200 legendCheck_.setSelected(legendOutput_);
201 okButton_.setEnabled(graphOutput_ || legendOutput_);
202 pathField_.requestFocus();
206 super.setVisible(visible);
228 colorOutput_ = color;
287 return legendOutput_;
static final String get(String key)
static final int BUTTON_GAP
static final int LABEL_GAP
void setPath(String path)
void setVisible(boolean visible)
void setLegendOutput(boolean output)
void setColorOutput(boolean color)
void setGraphOutput(boolean output)
static final int CONTENTS_GAP
static final int BORDER_GAP
static final int ITEM_GAP
output(gif_dest_ptr dinfo, int code)