List of usage examples for org.jfree.ui StrokeSample StrokeSample
public StrokeSample(final Stroke stroke)
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultNumberAxisEditor.java
/** * Standard constructor: builds a property panel for the specified axis. * /*from w w w.j av a 2 s . c o m*/ * @param axis * the axis, which should be changed. */ public DefaultNumberAxisEditor(NumberAxis axis) { super(axis); this.autoRange = axis.isAutoRange(); this.minimumValue = axis.getLowerBound(); this.maximumValue = axis.getUpperBound(); this.gridPaintSample = new PaintSample(Color.blue); this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples = new StrokeSample[3]; 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)); JTabbedPane other = getOtherTabs(); JPanel range = new JPanel(new LCBLayout(3)); range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); range.add(new JPanel()); this.autoRangeCheckBox = new JCheckBox(localizationResources.getString("Auto-adjust_range"), this.autoRange); this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff"); this.autoRangeCheckBox.addActionListener(this); range.add(this.autoRangeCheckBox); range.add(new JPanel()); range.add(new JLabel(localizationResources.getString("Minimum_range_value"))); this.minimumRangeValue = new JTextField(Double.toString(this.minimumValue)); this.minimumRangeValue.setEnabled(!this.autoRange); this.minimumRangeValue.setActionCommand("MinimumRange"); this.minimumRangeValue.addActionListener(this); this.minimumRangeValue.addFocusListener(this); range.add(this.minimumRangeValue); range.add(new JPanel()); range.add(new JLabel(localizationResources.getString("Maximum_range_value"))); this.maximumRangeValue = new JTextField(Double.toString(this.maximumValue)); this.maximumRangeValue.setEnabled(!this.autoRange); this.maximumRangeValue.setActionCommand("MaximumRange"); this.maximumRangeValue.addActionListener(this); this.maximumRangeValue.addFocusListener(this); range.add(this.maximumRangeValue); range.add(new JPanel()); other.add(localizationResources.getString("Range"), range); }
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultPlotEditor.java
/** * Standard constructor - constructs a panel for editing the properties of * the specified plot.//from w ww . j a v a2 s .c om * <P> * In designing the panel, we need to be aware that subclasses of Plot will * need to implement subclasses of PlotPropertyEditPanel - so we need to * leave one or two 'slots' where the subclasses can extend the user * interface. * * @param plot * the plot, which should be changed. */ public DefaultPlotEditor(Plot plot) { this.plotInsets = plot.getInsets(); this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint()); this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke()); this.outlinePaintSample = new PaintSample(plot.getOutlinePaint()); // Disabled because makes no sense for us // if (plot instanceof CategoryPlot) { // this.plotOrientation = ((CategoryPlot) plot).getOrientation(); // } else if (plot instanceof XYPlot) { // this.plotOrientation = ((XYPlot) plot).getOrientation(); // } if (plot instanceof CategoryPlot) { CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer(); if (renderer instanceof LineAndShapeRenderer) { LineAndShapeRenderer r = (LineAndShapeRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getBaseLinesVisible()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } else if (plot instanceof XYPlot) { XYItemRenderer renderer = ((XYPlot) plot).getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getPlotLines()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } setLayout(new BorderLayout()); this.availableStrokeSamples = new StrokeSample[4]; 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)); // create a panel for the settings... JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), plot.getPlotType() + localizationResources.getString(":"))); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder(localizationResources.getString("General"))); JPanel interior = new JPanel(new LCBLayout(7)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); interior.add(new JLabel(localizationResources.getString("Outline_stroke"))); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (StrokeSample s : this.availableStrokeSamples) { model.addElement(s.getStroke()); } this.cbOutlineStroke = new JComboBox(model); this.cbOutlineStroke.setSelectedItem(this.outlineStrokeSample.getStroke()); this.cbOutlineStroke.setRenderer(new StrokeComboboxRenderer()); interior.add(this.cbOutlineStroke); interior.add(new JLabel()); interior.add(new JLabel(localizationResources.getString("Outline_Paint"))); JButton button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("OutlinePaint"); button.addActionListener(this); interior.add(this.outlinePaintSample); interior.add(button); interior.add(new JLabel(localizationResources.getString("Background_paint"))); button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("BackgroundPaint"); button.addActionListener(this); interior.add(this.backgroundPaintSample); interior.add(button); // Disabled because makes no sense for us // if (this.plotOrientation != null) { // boolean isVertical = // this.plotOrientation.equals(PlotOrientation.VERTICAL); // int index = isVertical ? ORIENTATION_VERTICAL : // ORIENTATION_HORIZONTAL; // interior.add(new // JLabel(localizationResources.getString("Orientation"))); // this.orientationCombo = new JComboBox(orientationNames); // this.orientationCombo.setSelectedIndex(index); // this.orientationCombo.setActionCommand("Orientation"); // this.orientationCombo.addActionListener(this); // interior.add(this.orientationCombo); // interior.add(new JPanel()); // } if (this.drawLines != null) { interior.add(new JLabel(localizationResources.getString("Draw_lines"))); this.drawLinesCheckBox = new JCheckBox(); this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue()); this.drawLinesCheckBox.setActionCommand("DrawLines"); this.drawLinesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawLinesCheckBox); } if (this.drawShapes != null) { interior.add(new JLabel(localizationResources.getString("Draw_shapes"))); this.drawShapesCheckBox = new JCheckBox(); this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue()); this.drawShapesCheckBox.setActionCommand("DrawShapes"); this.drawShapesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawShapesCheckBox); } general.add(interior, BorderLayout.NORTH); JPanel appearance = new JPanel(new BorderLayout()); appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); appearance.add(general, BorderLayout.NORTH); JTabbedPane tabs = new JTabbedPane(); tabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); Axis domainAxis = null; if (plot instanceof CategoryPlot) { domainAxis = ((CategoryPlot) plot).getDomainAxis(); } else if (plot instanceof XYPlot) { domainAxis = ((XYPlot) plot).getDomainAxis(); } this.domainAxisPropertyPanel = DefaultAxisEditor.getInstance(domainAxis); if (this.domainAxisPropertyPanel != null) { this.domainAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Domain_Axis"), this.domainAxisPropertyPanel); } Axis rangeAxis = null; if (plot instanceof CategoryPlot) { rangeAxis = ((CategoryPlot) plot).getRangeAxis(); } else if (plot instanceof XYPlot) { rangeAxis = ((XYPlot) plot).getRangeAxis(); } this.rangeAxisPropertyPanel = DefaultAxisEditor.getInstance(rangeAxis); if (this.rangeAxisPropertyPanel != null) { this.rangeAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Range_Axis"), this.rangeAxisPropertyPanel); } tabs.add(localizationResources.getString("Appearance"), appearance); panel.add(tabs); add(panel); }
From source file:org.gumtree.vis.awt.time.TimePlotChartEditor.java
private JPanel createCurvesPanel() { JPanel wrap = new JPanel(new BorderLayout()); JPanel curves = new JPanel(new BorderLayout()); curves.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // JPanel general = new JPanel(new BorderLayout()); // general.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "General")); ////from www . j a v a 2 s . c o m // JPanel inner = new JPanel(new LCBLayout(6)); // inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); // // inner.add(new JLabel("Show Marker")); // showMarker = new JCheckBox(); // showMarker.setActionCommand(SHOW_MARKER_COMMAND); // showMarker.addActionListener(this); // inner.add(showMarker); // inner.add(new JLabel()); // inner.add(new JLabel("Show Error")); // showError = new JCheckBox(); // showError.setActionCommand(SHOW_ERROR_COMMAND); // showError.addActionListener(this); // inner.add(showError); // inner.add(new JLabel()); // // general.add(inner, BorderLayout.NORTH); // curves.add(general, BorderLayout.NORTH); JPanel individual = new JPanel(new BorderLayout()); individual.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Individual Curve")); JPanel interior = new JPanel(new LCBLayout(7)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); int numberOfDataset = chart.getXYPlot().getDatasetCount(); currentDataset = null; currentSeriesIndex = -1; List<String> seriesNames = new ArrayList<String>(); for (int i = 0; i < numberOfDataset; i++) { XYDataset dataset = chart.getXYPlot().getDataset(i); if (dataset != null && dataset instanceof ITimeSeriesSet) { int numberOfSeries = dataset.getSeriesCount(); for (int j = 0; j < numberOfSeries; j++) { String seriesName = (String) dataset.getSeriesKey(j); seriesNames.add(seriesName); if (seriesName.equals(currentSeriesKey)) { currentDataset = (IDataset) dataset; currentSeriesIndex = j; } } } } if ((currentDataset == null || currentSeriesIndex < 0) && seriesNames.size() > 0) { for (int i = 0; i < numberOfDataset; i++) { XYDataset dataset = chart.getXYPlot().getDataset(i); if (dataset != null && dataset instanceof ITimeSeriesSet && dataset.getSeriesCount() > 0) { currentDataset = (IDataset) dataset; currentSeriesIndex = 0; currentSeriesKey = (String) dataset.getSeriesKey(currentSeriesIndex); break; } } } //Select curve combo this.seriesCombo = new JComboBox(seriesNames.toArray()); seriesCombo.setActionCommand(CHANGE_CURVE_COMMAND); seriesCombo.addActionListener(this); interior.add(new JLabel("Select Curve")); interior.add(seriesCombo); interior.add(new JLabel("")); interior.add(new JLabel("Curve Stroke")); curveStrokeSample = new StrokeSample(new BasicStroke()); curveStrokeSample.setEnabled(false); interior.add(curveStrokeSample); // JButton button = new JButton(localizationResources.getString("Edit...")); Float[] strokes = new Float[] { 0f, 0.2f, 0.5f, 1f, 1.5f, 2f, 3f }; strokeCombo = new JComboBox(strokes); strokeCombo.setActionCommand(CURVE_STROCK_COMMAND); strokeCombo.addActionListener(this); interior.add(strokeCombo); interior.add(new JLabel("Curve Colour")); curveColorPaint = new PaintSample(chart.getBackgroundPaint()); interior.add(curveColorPaint); JButton button = new JButton(localizationResources.getString("Edit...")); button.setActionCommand(CURVE_COLOR_COMMAND); button.addActionListener(this); interior.add(button); interior.add(new JLabel("Marker Visible")); showMarker = new JCheckBox(); showMarker.setActionCommand(SHOW_MARKER_COMMAND); showMarker.addActionListener(this); interior.add(showMarker); interior.add(new JLabel()); interior.add(new JLabel("Marker Shape")); shapeLabel = new JLabel(); interior.add(shapeLabel); Integer[] shapeIndex = new Integer[MarkerShape.size]; for (int i = 0; i < shapeIndex.length; i++) { shapeIndex[i] = i; } shapeCombo = new JComboBox(shapeIndex); comboRender = new ImageComboRender(); comboRender.setShapes(StaticValues.LOCAL_SHAPE_SERIES); shapeCombo.setRenderer(comboRender); shapeCombo.setMaximumRowCount(7); shapeCombo.setActionCommand(MARKER_SHAPE_COMMAND); shapeCombo.addActionListener(this); interior.add(shapeCombo); interior.add(new JLabel("Marker Filled")); markerFilled = new JCheckBox(); markerFilled.setActionCommand(MARKER_FILLED_COMMAND); markerFilled.addActionListener(this); interior.add(markerFilled); interior.add(new JLabel()); interior.add(new JLabel("Curve Visable")); curveVisable = new JCheckBox(); curveVisable.setActionCommand(CURVE_VISIBLE_COMMAND); curveVisable.addActionListener(this); interior.add(curveVisable); interior.add(new JLabel()); individual.add(interior, BorderLayout.NORTH); curves.add(individual, BorderLayout.NORTH); curves.setName("Curves"); wrap.setName("Curves"); wrap.add(curves, BorderLayout.NORTH); return wrap; }
From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java
private JPanel createCurvesPanel() { JPanel wrap = new JPanel(new BorderLayout()); JPanel curves = new JPanel(new BorderLayout()); curves.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "General")); JPanel inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); inner.add(new JLabel("Show Marker")); showMarker = new JCheckBox(); showMarker.setActionCommand(SHOW_MARKER_COMMAND); showMarker.addActionListener(this); inner.add(showMarker);//w w w . j a v a 2 s . co m inner.add(new JLabel()); inner.add(new JLabel("Show Error")); showError = new JCheckBox(); showError.setActionCommand(SHOW_ERROR_COMMAND); showError.addActionListener(this); inner.add(showError); inner.add(new JLabel()); general.add(inner, BorderLayout.NORTH); curves.add(general, BorderLayout.NORTH); JPanel individual = new JPanel(new BorderLayout()); individual.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Individual")); JPanel interior = new JPanel(new LCBLayout(6)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); XYDataset dataset = chart.getXYPlot().getDataset(); int numberOfSeries = dataset.getSeriesCount(); String[] seriesNames = new String[numberOfSeries]; currentSeriesIndex = -1; for (int i = 0; i < numberOfSeries; i++) { seriesNames[i] = (String) dataset.getSeriesKey(i); if (seriesNames[i].equals(currentSeriesKey)) { currentSeriesIndex = i; } } if (currentSeriesIndex < 0 && seriesNames.length > 0) { currentSeriesIndex = 0; currentSeriesKey = seriesNames[currentSeriesIndex]; } //Select curve combo this.seriesCombo = new JComboBox(seriesNames); seriesCombo.setActionCommand(CHANGE_CURVE_COMMAND); seriesCombo.addActionListener(this); interior.add(new JLabel("Select Curve")); interior.add(seriesCombo); interior.add(new JLabel("")); interior.add(new JLabel("Curve Stroke")); curveStrokeSample = new StrokeSample(new BasicStroke()); curveStrokeSample.setEnabled(false); interior.add(curveStrokeSample); // JButton button = new JButton(localizationResources.getString("Edit...")); Float[] strokes = new Float[] { 0f, 0.2f, 0.5f, 1f, 1.5f, 2f, 3f }; strokeCombo = new JComboBox(strokes); strokeCombo.setActionCommand(CURVE_STROCK_COMMAND); strokeCombo.addActionListener(this); interior.add(strokeCombo); interior.add(new JLabel("Curve Colour")); curveColorPaint = new PaintSample(chart.getBackgroundPaint()); interior.add(curveColorPaint); JButton button = new JButton(localizationResources.getString("Edit...")); button.setActionCommand(CURVE_COLOR_COMMAND); button.addActionListener(this); interior.add(button); interior.add(new JLabel("Marker Shape")); shapeLabel = new JLabel(); interior.add(shapeLabel); Integer[] shapeIndex = new Integer[MarkerShape.size]; for (int i = 0; i < shapeIndex.length; i++) { shapeIndex[i] = i; } shapeCombo = new JComboBox(shapeIndex); comboRender = new ImageComboRender(); comboRender.setShapes(StaticValues.LOCAL_SHAPE_SERIES); shapeCombo.setRenderer(comboRender); shapeCombo.setMaximumRowCount(7); shapeCombo.setActionCommand(MARKER_SHAPE_COMMAND); shapeCombo.addActionListener(this); interior.add(shapeCombo); interior.add(new JLabel("Marker Filled")); markerFilled = new JCheckBox(); markerFilled.setActionCommand(MARKER_FILLED_COMMAND); markerFilled.addActionListener(this); interior.add(markerFilled); interior.add(new JLabel()); interior.add(new JLabel("Curve Visable")); curveVisable = new JCheckBox(); curveVisable.setActionCommand(CURVE_VISIBLE_COMMAND); curveVisable.addActionListener(this); interior.add(curveVisable); interior.add(new JLabel()); individual.add(interior, BorderLayout.NORTH); curves.add(individual); curves.setName("Curves"); wrap.setName("Curves"); wrap.add(curves, BorderLayout.NORTH); return wrap; }