List of usage examples for java.awt Adjustable VERTICAL
int VERTICAL
To view the source code for java.awt Adjustable VERTICAL.
Click Source Link
From source file:org.cds06.speleograph.graph.ValueAxisEditor.java
public ValueAxisEditor(NumberAxis axis) { super();//from w w w. j a v a 2s. c om this.axis = axis; this.oldLowValue = axis.getLowerBound(); this.oldHighValue = axis.getUpperBound(); this.maxField = new JTextField(Double.toString(axis.getUpperBound())); this.lowField = new JTextField(Double.toString(axis.getLowerBound())); int max = (int) (axis.getUpperBound() / 5); translateSlider = new JSlider(Adjustable.VERTICAL, -max, max, 0); homotSlider = new JSlider(Adjustable.VERTICAL, -max, max, 0); construct(); setTitle(I18nSupport.translate("graph.valueAxisEditor")); }
From source file:com.rapidminer.gui.plotter.charts.BarChartPlotter.java
@Override public void updatePlotter() { final int categoryCount = prepareData(); SwingUtilities.invokeLater(new Runnable() { @Override// w w w . j av a 2s. co m public void run() { scrollablePlotterPanel.remove(viewScrollBar); } }); CategoryDataset usedCategoryDataSet = categoryDataSet; if (categoryCount > MAX_CATEGORY_VIEW_COUNT && showScrollbar) { if (orientationIndex == ORIENTATION_TYPE_VERTICAL) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { viewScrollBar.setOrientation(Adjustable.HORIZONTAL); scrollablePlotterPanel.add(viewScrollBar, BorderLayout.SOUTH); } }); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { viewScrollBar.setOrientation(Adjustable.VERTICAL); scrollablePlotterPanel.add(viewScrollBar, BorderLayout.EAST); } }); } this.slidingCategoryDataSet = new SlidingCategoryDataset(categoryDataSet, 0, MAX_CATEGORY_VIEW_COUNT); viewScrollBar.setMaximum(categoryCount); viewScrollBar.setValue(0); usedCategoryDataSet = this.slidingCategoryDataSet; } else { this.slidingCategoryDataSet = null; } if (categoryCount <= MAX_CATEGORIES) { JFreeChart chart = ChartFactory.createBarChart(null, // chart title null, // domain axis label null, // range axis label usedCategoryDataSet, // data orientationIndex == ORIENTATION_TYPE_VERTICAL ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, // orientation false, // include legend if group by column is set true, // tooltips false // URLs ); // set the background color for the chart... chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLabelFont(LABEL_FONT_BOLD); domainAxis.setTickLabelFont(LABEL_FONT); String domainName = groupByColumn >= 0 ? dataTable.getColumnName(groupByColumn) : null; domainAxis.setLabel(domainName); // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d)); } // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabelFont(LABEL_FONT_BOLD); rangeAxis.setTickLabelFont(LABEL_FONT); String rangeName = valueColumn >= 0 ? dataTable.getColumnName(valueColumn) : null; rangeAxis.setLabel(rangeName); // bar renderer double[] colorValues = null; if (groupByColumn >= 0 && this.dataTable.isNominal(groupByColumn)) { colorValues = new double[this.dataTable.getNumberOfValues(groupByColumn)]; } else { colorValues = new double[categoryDataSet.getColumnCount()]; } for (int i = 0; i < colorValues.length; i++) { colorValues[i] = i; } BarRenderer renderer = new ColorizedBarRenderer(colorValues); renderer.setBarPainter(new RapidBarPainter()); renderer.setDrawBarOutline(true); int size = categoryDataSet.getRowCount(); if (size > 1) { for (int i = 0; i < size; i++) { renderer.setSeriesPaint(i, getColorProvider(true).getPointColor(i / (double) (size - 1))); } } plot.setRenderer(renderer); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } if (panel != null) { panel.setChart(chart); } else { panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN); scrollablePlotterPanel.add(panel, BorderLayout.CENTER); final ChartPanelShiftController controller = new ChartPanelShiftController(panel); panel.addMouseListener(controller); panel.addMouseMotionListener(controller); } // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); } else { // LogService.getGlobal().logNote("Too many columns (" + categoryCount + // "), this chart is only able to plot up to " + MAX_CATEGORIES + // " different categories."); LogService.getRoot().log(Level.INFO, "com.rapidminer.gui.plotter.charts.BarChartPlotter.too_many_columns", new Object[] { categoryCount, MAX_CATEGORIES }); } }
From source file:org.kepler.gui.KeplerGraphFrame.java
/** * Override BasicGraphFrame._initBasicGraphFrame() *//*w w w. j a v a 2 s .c om*/ @Override protected void _initBasicGraphFrame() { /** * @todo - FIXME - Need to move this further up the hierarchy, so other * types of frames use it too. Don't put it in a launcher class * like KeplerApplication, because it then gets overridden later, * elsewhere in PTII */ StaticGUIResources.setLookAndFeel(); _initBasicGraphFrameInitialization(); _dropTarget = BasicGraphFrameExtension.getDropTarget(_jgraph); // add a CanvasDropTargetListener so that other classes can get CanvasDropTargetListener listener = CanvasDropTargetListener.getInstance(); _dropTarget.registerAdditionalListener(listener); ActionListener deletionListener = new DeletionListener(); _rightComponent.registerKeyboardAction(deletionListener, "Delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); _rightComponent.registerKeyboardAction(deletionListener, "BackSpace", KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); _initBasicGraphFrameRightComponent(); _jgraph.setRequestFocusEnabled(true); // Background color is parameterizable by preferences. Configuration configuration = getConfiguration(); if (configuration != null) { try { // Set the PtolemyPreference to the desired background. // See // http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2321#c14 PtolemyPreferences preferences = PtolemyPreferences .getPtolemyPreferencesWithinConfiguration(configuration); if (_isDebugging) { _log.debug("bg: " + BACKGROUND_COLOR); } if (preferences != null) { float[] components = new float[4]; // Make sure we get only 4 elements in case the color space // is bigger than 4 components = BACKGROUND_COLOR.getComponents(components); preferences.backgroundColor.setExpression("{" + components[0] + "," + components[1] + "," + components[2] + "," + components[3] + "}"); _rightComponent.setBackground(preferences.backgroundColor.asColor()); if (_isDebugging) { _log.debug("desired background: " + BACKGROUND_COLOR + " actual background: " + preferences.backgroundColor.asColor()); } } } catch (IllegalActionException e1) { // Ignore the exception and use the default color. } } _initBasicGraphFrameRightComponentMouseListeners(); try { // The SizeAttribute property is used to specify the size // of the JGraph component. Unfortunately, with Swing's // mysterious and undocumented handling of component sizes, // there appears to be no way to control the size of the // JGraph from the size of the Frame, which is specified // by the WindowPropertiesAttribute. SizeAttribute size = (SizeAttribute) getModel().getAttribute("_vergilSize", SizeAttribute.class); if (size != null) { size.setSize(_jgraph); } else { // Set the default size. // Note that the location is of the frame, while the size // is of the scrollpane. _jgraph.setPreferredSize(new Dimension(600, 400)); } _initBasicGraphFrameSetZoomAndPan(); } catch (Exception ex) { // Ignore problems here. Errors simply result in a default // size and location. } // Create the panner. _graphPanner = new JCanvasPanner(_jgraph); _horizontalScrollBar = new JScrollBar(Adjustable.HORIZONTAL); _verticalScrollBar = new JScrollBar(Adjustable.VERTICAL); // see if we want scrollbars on the canvas or not // the answer defaults to 'no' CanvasNavigationModifierFactory CNMfactory = (CanvasNavigationModifierFactory) getConfiguration() .getAttribute("canvasNavigationModifier"); if (CNMfactory != null) { // get the scrollbar flag from the factory if // it exists in the config ScrollBarModifier modifier = CNMfactory.createScrollBarModifier(); _scrollBarFlag = modifier.getScrollBarModifier(); } _canvasPanel = new JPanel(); _canvasPanel.setBorder(null); _canvasPanel.setLayout(new BorderLayout()); if (_scrollBarFlag) { _canvasPanel.add(_horizontalScrollBar, BorderLayout.SOUTH); _canvasPanel.add(_verticalScrollBar, BorderLayout.EAST); _horizontalScrollBar.setModel(_jgraph.getGraphPane().getCanvas().getHorizontalRangeModel()); _verticalScrollBar.setModel(_jgraph.getGraphPane().getCanvas().getVerticalRangeModel()); _horizontalScrollBarListener = new ScrollBarListener(_horizontalScrollBar); _verticalScrollBarListener = new ScrollBarListener(_verticalScrollBar); _horizontalScrollBar.addAdjustmentListener(_horizontalScrollBarListener); _verticalScrollBar.addAdjustmentListener(_verticalScrollBarListener); } // NOTE: add _rightComponent instead of _jgraph since _rightComponent // may be sub-divided into tabbed panes. // see http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3708 _canvasPanel.add(_rightComponent, BorderLayout.CENTER); TabManager tabman = TabManager.getInstance(); tabman.initializeTabs(this); ViewManager viewman = ViewManager.getInstance(); viewman.initializeViews(this); try { viewman.addCanvasToLocation(_canvasPanel, this); } catch (Exception e) { throw new RuntimeException("Could not add canvas panel: " + e.getMessage()); } // _jgraph.setMinimumSize(new Dimension(0, 0)); getContentPane().add(viewman.getViewArea(this), BorderLayout.CENTER); // The toolbar panel is the container that contains the main toolbar and // any additional toolbars JPanel toolbarPanel = new JPanel(); toolbarPanel.setLayout(new BoxLayout(toolbarPanel, BoxLayout.Y_AXIS)); // They // stack _toolbar = new JToolBar(); // The main Kepler toolbar toolbarPanel.add(_toolbar); getContentPane().add(toolbarPanel, BorderLayout.NORTH); // Place the // toolbar panel _initBasicGraphFrameToolBarZoomButtons(); _initBasicGraphFrameActions(); // Add a weak reference to this to keep track of all // the graph frames that have been created. _openGraphFrames.add(this); System.gc(); }