/** * Returns a list cell renderer for the stroke, so the sample can be displayed in a list or * combo. * * @param list the list. * @param value the value. * @param index the index. * @param isSelected selected? * @param cellHasFocus focussed? * * @return the component for rendering. */ public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { if (value instanceof StrokeSample) { final StrokeSample in = (StrokeSample) value; setStroke(in.getStroke()); } return this; }
/** * Sets the stroke object being displayed and repaints the component. * * @param stroke the stroke (<code>null</code> permitted). */ public void setStroke(final Stroke stroke) { this.stroke = stroke; repaint(); }
/** * Creates a StrokeSample for the specified stroke. * * @param stroke the sample stroke (<code>null</code> permitted). */ public StrokeSample(final Stroke stroke) { this.stroke = stroke; this.preferredSize = new Dimension(80, 18); setPreferredSize(this.preferredSize); }
/** * Creates a panel containing a combo-box that allows the user to select * one stroke from a list of available strokes. * * @param current the current stroke sample. * @param available an array of 'available' stroke samples. */ public StrokeChooserPanel(StrokeSample current, StrokeSample[] available) { setLayout(new BorderLayout()); // we've changed the behaviour here to populate the combo box // with Stroke objects directly - ideally we'd change the signature // of the constructor too...maybe later. DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < available.length; i++) { model.addElement(available[i].getStroke()); } this.selector = new JComboBox(model); this.selector.setSelectedItem(current.getStroke()); this.selector.setRenderer(new StrokeSample(null)); add(this.selector); // Changes due to focus problems!! DZ this.selector.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent evt) { getSelector().transferFocus(); } }); }
/** * Returns a list cell renderer for the stroke, so the sample can be * displayed in a list or combo. * * @param list the list. * @param value the value. * @param index the index. * @param isSelected selected? * @param cellHasFocus focussed? * * @return the component for rendering. */ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof Stroke) { setStroke((Stroke) value); } else { setStroke(null); } return this; }
/** * Creates a panel containing a combo-box that allows the user to select * one stroke from a list of available strokes. * * @param current the current stroke sample. * @param available an array of 'available' stroke samples. */ public StrokeChooserPanel(final StrokeSample current, final StrokeSample[] available) { setLayout(new BorderLayout()); this.selector = new JComboBox(available); this.selector.setSelectedItem(current); this.selector.setRenderer(new StrokeSample(new BasicStroke(1))); add(this.selector); // Changes due to focus problems!! DZ this.selector.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent evt) { getSelector().transferFocus(); } }); }
/** * Returns the current outline stroke. * * @return The current outline stroke (possibly <code>null</code>). */ public Stroke getOutlineStroke() { return this.outlineStrokeSample.getStroke(); }
/** * Creates a panel containing a combo-box that allows the user to select * one stroke from a list of available strokes. * * @param current the current stroke sample. * @param available an array of 'available' stroke samples. */ public StrokeChooserPanel(StrokeSample current, StrokeSample[] available) { setLayout(new BorderLayout()); // we've changed the behaviour here to populate the combo box // with Stroke objects directly - ideally we'd change the signature // of the constructor too...maybe later. DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < available.length; i++) { model.addElement(available[i].getStroke()); } this.selector = new JComboBox(model); this.selector.setSelectedItem(current.getStroke()); this.selector.setRenderer(new StrokeSample(null)); add(this.selector); // Changes due to focus problems!! DZ this.selector.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent evt) { getSelector().transferFocus(); } }); }
/** * Returns a list cell renderer for the stroke, so the sample can be * displayed in a list or combo. * * @param list the list. * @param value the value. * @param index the index. * @param isSelected selected? * @param cellHasFocus focussed? * * @return the component for rendering. */ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof Stroke) { setStroke((Stroke) value); } else { setStroke(null); } return this; }
this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples[0] = new StrokeSample( new BasicStroke(1.0f)); this.availableStrokeSamples[1] = new StrokeSample( new BasicStroke(2.0f)); this.availableStrokeSamples[2] = new StrokeSample( new BasicStroke(3.0f));
/** * Returns the selected stroke. * * @return the selected stroke. */ public Stroke getSelectedStroke() { final StrokeSample sample = (StrokeSample) this.selector.getSelectedItem(); return sample.getStroke(); }
/** * Allow the user to change the outline stroke. */ private void attemptOutlineStrokeSelection() { StrokeChooserPanel panel = new StrokeChooserPanel( this.outlineStrokeSample, this.availableStrokeSamples); int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Stroke_Selection"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { this.outlineStrokeSample.setStroke(panel.getSelectedStroke()); } }
this.plotInsets = plot.getInsets(); this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint()); this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke()); this.outlinePaintSample = new PaintSample(plot.getOutlinePaint()); if (plot instanceof CategoryPlot) { this.availableStrokeSamples[0] = new StrokeSample(null); this.availableStrokeSamples[1] = new StrokeSample( new BasicStroke(1.0f)); this.availableStrokeSamples[2] = new StrokeSample( new BasicStroke(2.0f)); this.availableStrokeSamples[3] = new StrokeSample( new BasicStroke(3.0f));
/** * Sets the stroke object being displayed and repaints the component. * * @param stroke the stroke (<code>null</code> permitted). */ public void setStroke(final Stroke stroke) { this.stroke = stroke; repaint(); }
/** * Creates a StrokeSample for the specified stroke. * * @param stroke the sample stroke (<code>null</code> permitted). */ public StrokeSample(final Stroke stroke) { this.stroke = stroke; this.preferredSize = new Dimension(80, 18); setPreferredSize(this.preferredSize); }
/** * Handle a grid stroke selection. */ private void attemptGridStrokeSelection() { StrokeChooserPanel panel = new StrokeChooserPanel(this.gridStrokeSample, this.availableStrokeSamples); int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Stroke_Selection"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { this.gridStrokeSample.setStroke(panel.getSelectedStroke()); } }
/** * Sets the Stroke object being displayed. * * @param stroke the stroke. */ public void setStroke(final Stroke stroke) { this.stroke = stroke; repaint(); }