List of usage examples for javax.swing JScrollBar getValue
public int getValue()
From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java
private void updateMessageEditor() { final JScrollBar vsb = myMessageScrollPane.getVerticalScrollBar(); int initialVerticalValue = vsb.getValue(); myMessageEditor.getDocument().removeDocumentListener(myDocumentListener); String sourceMessage = myMessage.getSourceMessage(); if (myMessage.getEncoding() == Hl7V2EncodingTypeEnum.XML) { myMessageEditor.setContentType("text/xml"); } else {/*from ww w . j a v a 2 s . c o m*/ myMessageEditor.setContentType("text/er7"); sourceMessage = sourceMessage.replace('\r', '\n'); } myMessageEditor.setText(sourceMessage); myMessageEditor.getDocument().addDocumentListener(myDocumentListener); final int verticalValue = Math.min(initialVerticalValue, vsb.getMaximum()); SwingUtilities.invokeLater(new Runnable() { public void run() { // myMessageEditor.setFont(Prefs.getHl7EditorFont()); vsb.setValue(verticalValue); } }); }
From source file:org.datacleaner.widgets.result.DateGapAnalyzerResultSwingRenderer.java
@Override public JComponent render(DateGapAnalyzerResult result) { final TaskSeriesCollection dataset = new TaskSeriesCollection(); final Set<String> groupNames = result.getGroupNames(); final TaskSeries completeDurationTaskSeries = new TaskSeries(LABEL_COMPLETE_DURATION); final TaskSeries gapsTaskSeries = new TaskSeries(LABEL_GAPS); final TaskSeries overlapsTaskSeries = new TaskSeries(LABEL_OVERLAPS); for (final String groupName : groupNames) { final String groupDisplayName; if (groupName == null) { if (groupNames.size() == 1) { groupDisplayName = "All"; } else { groupDisplayName = LabelUtils.NULL_LABEL; }//from w w w. j ava 2s. c om } else { groupDisplayName = groupName; } final TimeInterval completeDuration = result.getCompleteDuration(groupName); final Task completeDurationTask = new Task(groupDisplayName, createTimePeriod(completeDuration.getFrom(), completeDuration.getTo())); completeDurationTaskSeries.add(completeDurationTask); // plot gaps { final SortedSet<TimeInterval> gaps = result.getGaps(groupName); int i = 1; Task rootTask = null; for (TimeInterval interval : gaps) { final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo()); if (rootTask == null) { rootTask = new Task(groupDisplayName, timePeriod); gapsTaskSeries.add(rootTask); } else { Task task = new Task(groupDisplayName + " gap" + i, timePeriod); rootTask.addSubtask(task); } i++; } } // plot overlaps { final SortedSet<TimeInterval> overlaps = result.getOverlaps(groupName); int i = 1; Task rootTask = null; for (TimeInterval interval : overlaps) { final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo()); if (rootTask == null) { rootTask = new Task(groupDisplayName, timePeriod); overlapsTaskSeries.add(rootTask); } else { Task task = new Task(groupDisplayName + " overlap" + i, timePeriod); rootTask.addSubtask(task); } i++; } } } dataset.add(overlapsTaskSeries); dataset.add(gapsTaskSeries); dataset.add(completeDurationTaskSeries); final SlidingGanttCategoryDataset slidingDataset = new SlidingGanttCategoryDataset(dataset, 0, GROUPS_VISIBLE); final JFreeChart chart = ChartFactory.createGanttChart( "Date gaps and overlaps in " + result.getFromColumnName() + " / " + result.getToColumnName(), result.getGroupColumnName(), "Time", slidingDataset, true, true, false); ChartUtils.applyStyles(chart); // make sure the 3 timeline types have correct coloring { final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDrawingSupplier(new DCDrawingSupplier(WidgetUtils.ADDITIONAL_COLOR_GREEN_BRIGHT, WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BLUE_BRIGHT)); } final int visibleLines = Math.min(GROUPS_VISIBLE, groupNames.size()); final ChartPanel chartPanel = ChartUtils.createPanel(chart, ChartUtils.WIDTH_WIDE, visibleLines * 50 + 200); chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent event) { Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); ChartEntity entity = event.getEntity(); if (entity instanceof PlotEntity) { cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR); } chartPanel.setCursor(cursor); } @Override public void chartMouseClicked(ChartMouseEvent event) { // do nothing } }); final JComponent decoratedChartPanel; final StringBuilder chartDescription = new StringBuilder("<html>"); chartDescription.append("<p>The chart displays the recorded timeline based on FROM and TO dates.</p>"); chartDescription.append( "<p>The <b>red items</b> represent gaps in the timeline and the <b>green items</b> represent points in the timeline where more than one record show activity.</p>"); chartDescription.append( "<p>You can <b>zoom in</b> by clicking and dragging the area that you want to examine in further detail.</p>"); if (groupNames.size() > GROUPS_VISIBLE) { final JScrollBar scroll = new JScrollBar(JScrollBar.VERTICAL); scroll.setMinimum(0); scroll.setMaximum(groupNames.size()); scroll.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { int value = e.getAdjustable().getValue(); slidingDataset.setFirstCategoryIndex(value); } }); chartPanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int scrollType = e.getScrollType(); if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int wheelRotation = e.getWheelRotation(); scroll.setValue(scroll.getValue() + wheelRotation); } } }); final DCPanel outerPanel = new DCPanel(); outerPanel.setLayout(new BorderLayout()); outerPanel.add(chartPanel, BorderLayout.CENTER); outerPanel.add(scroll, BorderLayout.EAST); chartDescription.append("<p>Use the right <b>scrollbar</b> to scroll up and down on the chart.</p>"); decoratedChartPanel = outerPanel; } else { decoratedChartPanel = chartPanel; } chartDescription.append("</html>"); final JLabel chartDescriptionLabel = new JLabel(chartDescription.toString()); final DCPanel panel = new DCPanel(); panel.setLayout(new VerticalLayout()); panel.add(chartDescriptionLabel); panel.add(decoratedChartPanel); return panel; }
From source file:org.eobjects.datacleaner.widgets.result.DateGapAnalyzerResultSwingRenderer.java
@Override public JComponent render(DateGapAnalyzerResult result) { final TaskSeriesCollection dataset = new TaskSeriesCollection(); final Set<String> groupNames = result.getGroupNames(); final TaskSeries completeDurationTaskSeries = new TaskSeries(LABEL_COMPLETE_DURATION); final TaskSeries gapsTaskSeries = new TaskSeries(LABEL_GAPS); final TaskSeries overlapsTaskSeries = new TaskSeries(LABEL_OVERLAPS); for (final String groupName : groupNames) { final String groupDisplayName; if (groupName == null) { if (groupNames.size() == 1) { groupDisplayName = "All"; } else { groupDisplayName = LabelUtils.NULL_LABEL; }//ww w .ja va 2 s.co m } else { groupDisplayName = groupName; } final TimeInterval completeDuration = result.getCompleteDuration(groupName); final Task completeDurationTask = new Task(groupDisplayName, createTimePeriod(completeDuration.getFrom(), completeDuration.getTo())); completeDurationTaskSeries.add(completeDurationTask); // plot gaps { final SortedSet<TimeInterval> gaps = result.getGaps(groupName); int i = 1; Task rootTask = null; for (TimeInterval interval : gaps) { final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo()); if (rootTask == null) { rootTask = new Task(groupDisplayName, timePeriod); gapsTaskSeries.add(rootTask); } else { Task task = new Task(groupDisplayName + " gap" + i, timePeriod); rootTask.addSubtask(task); } i++; } } // plot overlaps { final SortedSet<TimeInterval> overlaps = result.getOverlaps(groupName); int i = 1; Task rootTask = null; for (TimeInterval interval : overlaps) { final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo()); if (rootTask == null) { rootTask = new Task(groupDisplayName, timePeriod); overlapsTaskSeries.add(rootTask); } else { Task task = new Task(groupDisplayName + " overlap" + i, timePeriod); rootTask.addSubtask(task); } i++; } } } dataset.add(overlapsTaskSeries); dataset.add(gapsTaskSeries); dataset.add(completeDurationTaskSeries); final SlidingGanttCategoryDataset slidingDataset = new SlidingGanttCategoryDataset(dataset, 0, GROUPS_VISIBLE); final JFreeChart chart = ChartFactory.createGanttChart( "Date gaps and overlaps in " + result.getFromColumnName() + " / " + result.getToColumnName(), result.getGroupColumnName(), "Time", slidingDataset, true, true, false); ChartUtils.applyStyles(chart); // make sure the 3 timeline types have correct coloring { final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDrawingSupplier(new DCDrawingSupplier(WidgetUtils.ADDITIONAL_COLOR_GREEN_BRIGHT, WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BLUE_BRIGHT)); } final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent event) { Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); ChartEntity entity = event.getEntity(); if (entity instanceof PlotEntity) { cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR); } chartPanel.setCursor(cursor); } @Override public void chartMouseClicked(ChartMouseEvent event) { // do nothing } }); final int visibleLines = Math.min(GROUPS_VISIBLE, groupNames.size()); chartPanel.setPreferredSize(new Dimension(0, visibleLines * 50 + 200)); final JComponent decoratedChartPanel; StringBuilder chartDescription = new StringBuilder(); chartDescription .append("<html><p>The chart displays the recorded timeline based on FROM and TO dates.<br/><br/>"); chartDescription.append( "The <b>red items</b> represent gaps in the timeline and the <b>green items</b> represent points in the timeline where more than one record show activity.<br/><br/>"); chartDescription.append( "You can <b>zoom in</b> by clicking and dragging the area that you want to examine in further detail."); if (groupNames.size() > GROUPS_VISIBLE) { final JScrollBar scroll = new JScrollBar(JScrollBar.VERTICAL); scroll.setMinimum(0); scroll.setMaximum(groupNames.size()); scroll.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { int value = e.getAdjustable().getValue(); slidingDataset.setFirstCategoryIndex(value); } }); chartPanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int scrollType = e.getScrollType(); if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int wheelRotation = e.getWheelRotation(); scroll.setValue(scroll.getValue() + wheelRotation); } } }); final DCPanel outerPanel = new DCPanel(); outerPanel.setLayout(new BorderLayout()); outerPanel.add(chartPanel, BorderLayout.CENTER); outerPanel.add(scroll, BorderLayout.EAST); chartDescription.append("<br/><br/>Use the right <b>scrollbar</b> to scroll up and down on the chart."); decoratedChartPanel = outerPanel; } else { decoratedChartPanel = chartPanel; } chartDescription.append("</p></html>"); final JLabel chartDescriptionLabel = new JLabel(chartDescription.toString()); chartDescriptionLabel.setBorder(new EmptyBorder(4, 10, 4, 10)); final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(decoratedChartPanel); split.add(chartDescriptionLabel); split.setDividerLocation(550); return split; }
From source file:lcmc.common.ui.ResourceGraph.java
protected final void initGraph(final Graph<Vertex, Edge> graph) { this.graph = graph; final Transformer<Vertex, Point2D> vlf = TransformerUtils.mapTransformer(getVertexLocations()); putVertexLocations();/*from www . j a v a 2 s. c o m*/ layout = new StaticLayout<Vertex, Edge>(graph, vlf) { /* remove the adjust locations part, because scaling is from 0, 0 */ @Override public void setSize(final Dimension size) { if (size != null) { this.size = size; initialize(); } } }; visualizationViewer = new VisualizationViewer<Vertex, Edge>(layout); visualizationViewer.setVertexToolTipTransformer(new MyVertexToolTipFunction<Vertex>()); visualizationViewer.setEdgeToolTipTransformer(new MyEdgeToolTipFunction<Edge>()); initializeRendering(visualizationViewer); /* scaling */ /* overwriting scaler so that zooming starts from point (0, 0) */ myScaler = getScalingControl(); /* picking and popups */ /* overwriting loadPlugins method only to set scaler */ final DefaultModalGraphMouse<Vertex, Edge> graphMouse = new DefaultModalGraphMouse<Vertex, Edge>() { @Override protected void loadPlugins() { super.loadPlugins(); ((ScalingGraphMousePlugin) scalingPlugin).setScaler(myScaler); remove(animatedPickingPlugin); animatedPickingPlugin = null; } }; visualizationViewer.setGraphMouse(graphMouse); graphMouse.add(new MyPopupGraphMousePlugin<Vertex, Edge>()); visualizationViewer.addGraphMouseListener(new MyGraphMouseListener<Vertex>()); visualizationViewer.setPickSupport(new ShapePickSupport<Vertex, Edge>(visualizationViewer, 50)); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); layout.initialize(); scrollPane = new GraphZoomScrollPane(visualizationViewer); final JScrollBar vScrollBar = scrollPane.getVerticalScrollBar(); visualizationViewer.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(final MouseWheelEvent e) { if ((e.getModifiers() & MouseWheelEvent.CTRL_MASK) > 0) { final int amount = e.getWheelRotation(); vScrollBar.setValue(vScrollBar.getValue() + amount * 20); e.consume(); visualizationViewer.repaint(); } } }); }
From source file:com.qspin.qtaste.ui.reporter.TestCaseReportTable.java
public void putEntry(TestResult tr, String campaignReportName) { boolean isInteractiveCommand = tr.getTestCaseDirectory().endsWith("QTaste_interactive"); String testReportName = TestResultsReportManager.getInstance().getReportName(); boolean isManualSUTStartOrStop = testReportName != null && testReportName.startsWith("Manual SUT"); if (interactive) { if (!isInteractiveCommand && !isManualSUTStartOrStop) { return; }/*from w w w . ja v a 2 s . c om*/ } else { if (isInteractiveCommand) { return; } if (campaignReportName != null && !campaignReportName.equals(runName)) { return; } if (campaignReportName == null && !runName.equals("Run1")) { return; } } if (!testCases.containsKey(tr)) { Object[] cols = new Object[7]; cols[TEST_CASE] = convertToUniqueTc(tr); cols[DETAILS] = tr.getExtraResultDetails(); if (tr.getReturnValue() != null) { cols[RESULT] = tr.getReturnValue(); } cols[STATUS] = getImage(tr.getStatus()); if (tr.getStatus() != TestResult.Status.RUNNING) { cols[EXEC_TIME] = tr.getFormattedElapsedTime(false); } TestBedConfiguration testbed = TestBedConfiguration.getInstance(); cols[TESTBED] = testbed.getFile().getName().replace("." + StaticConfiguration.CAMPAIGN_FILE_EXTENSION, ""); cols[TC] = tr; //tcModel.addRow(cols); Integer rowNum = new Integer(tcModel.getRowCount()); testCases.put(tr, rowNum); long currentScrollBarMax = 0; JScrollPane scrollPane = (JScrollPane) tcTable.getParent().getParent(); JScrollBar scrollbar = scrollPane.getVerticalScrollBar(); if (scrollbar != null) { if (scrollbar.getMouseListeners().length == 1) { scrollPane.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { userScrollPosition = true; } }); scrollbar.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { userScrollPosition = true; } @Override public void mousePressed(MouseEvent e) { userScrollPosition = true; } }); } currentScrollBarMax = scrollbar.getMaximum() - scrollbar.getSize().height - tcTable.getRowHeight(); tcModel.addRow(cols); if (!userScrollPosition) { tcTable.scrollRectToVisible(tcTable.getCellRect(tcModel.getRowCount() - 1, 0, true)); return; } else if (scrollbar.getValue() >= currentScrollBarMax) { tcTable.scrollRectToVisible(tcTable.getCellRect(tcModel.getRowCount() - 1, 0, true)); userScrollPosition = false; return; } else { System.out.println("Scrollbar pos=" + scrollbar.getValue() + "; max=" + currentScrollBarMax + "height=" + scrollbar.getSize().height); } } else { tcModel.addRow(cols); } } else { updateTestCaseRow(tr); } }
From source file:org.forester.archaeopteryx.ControlPanel.java
void zoomOutY(final float factor) { final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor(0.9f);//from w w w . ja v a2s . co m if ((treepanel.getYdistance() * factor) > 0.0) { final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); final double x = (sb.getMaximum() - sb.getMinimum()) / (sb.getValue() + (sb.getVisibleAmount() / 2.0)); treepanel.setYdistance((treepanel.getYdistance() * factor)); getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); sb.setValue(ForesterUtil .roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0))); treepanel.resetPreferredSize(); treepanel.updateOvSizes(); } }
From source file:lcmc.gui.ResourceGraph.java
/** Inits the graph. */ protected final void initGraph(final Graph<Vertex, Edge> graph) { this.graph = graph; final Transformer<Vertex, Point2D> vlf = TransformerUtils.mapTransformer(getVertexLocations()); putVertexLocations();/*from w w w . j av a 2 s . c om*/ layout = new StaticLayout<Vertex, Edge>(graph, vlf) { /* remove the adjust locations part, because scraling is from 0, 0 */ @Override public final void setSize(final Dimension size) { if (size != null) { this.size = size; initialize(); } } }; vv = new VisualizationViewer<Vertex, Edge>(layout); vv.getRenderContext().setEdgeArrowTransformer(new MyEdgeArrowFunction<Vertex, Edge>()); vv.getRenderContext().setEdgeLabelClosenessTransformer( new ConstantDirectionalEdgeValueTransformer<Vertex, Edge>(0.5, 0.5)); vv.getRenderContext().setVertexShapeTransformer(new MyVertexShapeSize<Vertex, Edge>(graph, vlf)); vv.getRenderContext().setVertexFillPaintTransformer( new MyPickableVertexPaintFunction<Vertex>(vv.getPickedVertexState(), false)); vv.getRenderContext().setVertexDrawPaintTransformer( new MyPickableVertexPaintFunction<Vertex>(vv.getPickedVertexState(), true)); vv.getRenderer().setVertexRenderer(pr); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); vv.setBackground(Tools.getDefaultColor("ResourceGraph.Background")); vv.setVertexToolTipTransformer(new MyVertexToolTipFunction<Vertex>()); vv.setEdgeToolTipTransformer(new MyEdgeToolTipFunction<Edge>()); vv.getRenderContext().setEdgeShapeTransformer(new MyLine<Vertex, Edge>()); vv.getRenderContext().setEdgeDrawPaintTransformer( new MyPickableEdgePaintFunction<Edge>(vv.getPickedEdgeState(), EDGE_DRAW_PAINT, EDGE_PICKED_PAINT)); vv.getRenderContext().setEdgeFillPaintTransformer( new MyPickableEdgePaintFunction<Edge>(vv.getPickedEdgeState(), EDGE_DRAW_PAINT, EDGE_PICKED_PAINT)); vv.getRenderContext().setArrowDrawPaintTransformer( new MyPickableEdgePaintFunction<Edge>(vv.getPickedEdgeState(), EDGE_DRAW_PAINT, EDGE_PICKED_PAINT)); vv.getRenderContext().setArrowFillPaintTransformer(new MyPickableArrowEdgePaintFunction<Edge>( vv.getPickedEdgeState(), EDGE_DRAW_PAINT, EDGE_PICKED_PAINT)); /* scaling */ /* overwriting scaler so that zooming starts from point (0, 0) */ myScaler = getScalingControl(); /* picking and popups */ /* overwriting loadPlugins method only to set scaler */ final DefaultModalGraphMouse<Vertex, Edge> graphMouse = new DefaultModalGraphMouse<Vertex, Edge>() { protected void loadPlugins() { super.loadPlugins(); ((ScalingGraphMousePlugin) scalingPlugin).setScaler(myScaler); remove(animatedPickingPlugin); animatedPickingPlugin = null; } }; vv.setGraphMouse(graphMouse); graphMouse.add(new MyPopupGraphMousePlugin<Vertex, Edge>()); vv.addGraphMouseListener(new MyGraphMouseListener<Vertex>()); vv.setPickSupport(new ShapePickSupport<Vertex, Edge>(vv, 50)); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); layout.initialize(); scrollPane = new GraphZoomScrollPane(vv); final JScrollBar vScrollBar = scrollPane.getVerticalScrollBar(); vv.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(final MouseWheelEvent e) { if ((e.getModifiers() & MouseWheelEvent.CTRL_MASK) > 0) { final int amount = e.getWheelRotation(); vScrollBar.setValue(vScrollBar.getValue() + amount * 20); e.consume(); vv.repaint(); } } }); }
From source file:org.forester.archaeopteryx.ControlPanel.java
void zoomInY(final float factor) { final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor(1.1f);// w w w. j av a 2s . c o m final double x = (sb.getMaximum() - sb.getMinimum()) / (sb.getValue() + (sb.getVisibleAmount() / 2.0)); treepanel.setYdistance((treepanel.getYdistance() * factor)); getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); sb.setValue( ForesterUtil.roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0))); treepanel.resetPreferredSize(); treepanel.updateOvSizes(); }
From source file:org.forester.archaeopteryx.ControlPanel.java
void zoomInX(final float factor, final float x_correction_factor) { final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar(); final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor(1f);//from w w w .ja v a 2 s . c o m if ((treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR) || (treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) || isDrawPhylogram(getMainPanel().getCurrentTabIndex()) || (getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP)) { final double x = (sb.getMaximum() - sb.getMinimum()) / (sb.getValue() + (sb.getVisibleAmount() / 2.0)); treepanel.setXdistance((treepanel.getXdistance() * factor)); treepanel.setXcorrectionFactor((treepanel.getXcorrectionFactor() * x_correction_factor)); getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); sb.setValue(ForesterUtil .roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0))); } else { final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue(); treepanel.setXdistance((treepanel.getXdistance() * factor)); treepanel.setXcorrectionFactor((treepanel.getXcorrectionFactor() * x_correction_factor)); getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); sb.setValue(sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount()); } treepanel.resetPreferredSize(); treepanel.updateOvSizes(); }
From source file:org.forester.archaeopteryx.ControlPanel.java
void zoomOutX(final float factor, final float x_correction_factor) { final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor(1f);/*from w ww .j av a 2s . c om*/ if ((treepanel.getXdistance() * factor) > 0.0) { final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar(); if ((treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR) || (treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) || isDrawPhylogram(getMainPanel().getCurrentTabIndex()) || (getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP)) { getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); final double x = (sb.getMaximum() - sb.getMinimum()) / (sb.getValue() + (sb.getVisibleAmount() / 2.0)); treepanel.setXdistance((treepanel.getXdistance() * factor)); treepanel.setXcorrectionFactor((treepanel.getXcorrectionFactor() * x_correction_factor)); getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); sb.setValue(ForesterUtil .roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0))); } else { final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue(); treepanel.setXdistance(treepanel.getXdistance() * factor); treepanel.setXcorrectionFactor(treepanel.getXcorrectionFactor() * x_correction_factor); if (x > 0) { getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); sb.setValue(sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount()); } } treepanel.resetPreferredSize(); treepanel.updateOvSizes(); } }