List of usage examples for java.awt.event MouseWheelEvent getWheelRotation
public int getWheelRotation()
From source file:net.sf.mzmine.modules.visualization.ida.IDAPlot.java
public void mouseWheelMoved(MouseWheelEvent event) { int notches = event.getWheelRotation(); if (notches < 0) { getXYPlot().getDomainAxis().resizeRange(1.0 / ZOOM_FACTOR); } else {/*from www .j ava 2 s. c om*/ getXYPlot().getDomainAxis().resizeRange(ZOOM_FACTOR); } }
From source file:api3.transform.PlotWave.java
private MouseWheelListener addZoomWheel() { return new MouseWheelListener() { private void zoomChartAxis(ChartPanel chartP, boolean increase) { int width = chartP.getMaximumDrawWidth() - chartP.getMinimumDrawWidth(); int height = chartP.getMaximumDrawHeight() - chartP.getMinimumDrawWidth(); if (increase) { chartP.zoomInDomain(width / 2, height / 2); } else { chartP.zoomOutDomain(width / 2, height / 2); }/*from w w w .ja v a 2s . c om*/ lastValue = SLIDER_DEFAULT_VALUE; slider.setValue(lastValue); } public synchronized void decreaseZoom(JComponent chart, boolean saveAction) { ChartPanel ch = (ChartPanel) chart; zoomChartAxis(ch, false); } public synchronized void increaseZoom(JComponent chart, boolean saveAction) { ChartPanel ch = (ChartPanel) chart; zoomChartAxis(ch, true); } @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) { return; } if (e.getWheelRotation() < 0) { increaseZoom((ChartPanel) e.getComponent(), true); } else { decreaseZoom((ChartPanel) e.getComponent(), true); } } }; }
From source file:org.fhaes.fhrecorder.view.GraphPanel.java
/** * Constructor for the Graphics Panel. Sets up layout and settings of all components. *///from w ww.j a v a 2s . c o m public GraphPanel() { data = FileController.getYearSummaryList(); setLayout(new MigLayout("", "[grow,right]", "[fill][300px,grow,fill][][]")); JButton customizeButton = new JButton("Customize"); customizeButton.setIcon(Builder.getImageIcon("configure.png")); customizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { showCustomizeWindow(); } }); zoomOutButton = new JButton(""); zoomOutButton.setIcon(Builder.getImageIcon("zoom_out.png")); zoomOutButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { setZoomLevel(zoomLevel + 1); } }); add(zoomOutButton, "flowx,cell 0 0"); zoomInButton = new JButton(""); zoomInButton.setIcon(Builder.getImageIcon("zoom_in.png")); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { setZoomLevel(zoomLevel - 1); } }); add(zoomInButton, "cell 0 0"); add(customizeButton, "cell 0 0,alignx right"); rigidArea = Box.createRigidArea(new Dimension(20, 20)); rigidArea.setMaximumSize(new Dimension(200, 20)); rigidArea.setMinimumSize(new Dimension(1, 20)); add(rigidArea, "cell 0 1"); colorPane = new ColorBarGraph(data); colorPane.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int notches = e.getWheelRotation(); setZoomLevel(zoomLevel + notches); } }); add(colorPane, "cell 0 1,growx"); scrollBar = new JScrollBar(); scrollBar.setMinimum(0); scrollBar.setMaximum(data.size()); scrollBar.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent event) { setChartsFirstCategoryIndex(event.getValue()); } }); overlayPane = new GraphSummaryOverlay(data); overlayPane.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int notches = e.getWheelRotation(); setZoomLevel(zoomLevel + notches); } }); add(overlayPane, "cell 0 2,growx"); scrollBar.setOrientation(JScrollBar.HORIZONTAL); add(scrollBar, "cell 0 3,growx"); refreshCharts(false); }
From source file:playground.sergioo.networkBusLaneAdder2012.gui.BusLaneAdderPanel.java
@Override public void mouseWheelMoved(MouseWheelEvent e) { this.requestFocus(); if (e.getWheelRotation() < 0) camera.zoomIn();//from w ww. j a v a2 s.c o m else if (e.getWheelRotation() > 0) camera.zoomOut(); repaint(); }
From source file:com.epiq.bitshark.ui.IVQPanel.java
/** * Initialized the graph/*from ww w. j av a 2 s .c o m*/ */ private void initGraph() { dataset = new XYSeriesCollection(); ivqSeries = new BasicSeries("I Versus Q"); dataset.addSeries(ivqSeries); graph = ChartFactory.createXYLineChart(null, // no title "", // no x-axis label "", // no y-axis label dataset, // data PlotOrientation.VERTICAL, false, // no legend false, // no tooltips false // no URLs ); graph.setBorderVisible(false); graph.setPadding(new RectangleInsets(-5, 0, 0, -0)); graph.setBackgroundPaint(null); graph.setAntiAlias(true); plot = (XYPlot) graph.getPlot(); plot.setBackgroundAlpha(0.0f); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(true); renderer.setSeriesPaint(0, Common.EPIQ_GREEN); } // X-axis setup plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setVisible(true); plot.getDomainAxis().setUpperBound(Math.pow(2, 13)); plot.getDomainAxis().setLowerBound(-Math.pow(2, 13)); // Y-axis setup plot.getRangeAxis().setAutoRange(false); plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setUpperBound(Math.pow(2, 13)); plot.getRangeAxis().setLowerBound(-Math.pow(2, 13)); chartPanel = new ChartPanel(graph, true, // properties true, // save false, true, // zoom false); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setOpaque(false); // enable zoom control via mouse wheel chartPanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int clicks = e.getWheelRotation(); plot.getRangeAxis().setUpperBound(plot.getRangeAxis().getUpperBound() - (clicks * 100)); plot.getRangeAxis().setLowerBound(plot.getRangeAxis().getLowerBound() + (clicks * 100)); } }); }
From source file:com.epiq.bitshark.ui.TimeDomainPanel.java
/** * Initializes the graph//from w w w .ja v a2s. c o m */ private void initGraph() { dataset = new XYSeriesCollection(); realSeries = new BasicSeries("Real"); imaginarySeries = new BasicSeries("Imaginary"); dataset.addSeries(realSeries); dataset.addSeries(imaginarySeries); graph = ChartFactory.createXYLineChart(null, // no title "", // no x-axis label "", // no y-axis label dataset, // data PlotOrientation.VERTICAL, false, // no legend false, // no tooltips false // no URLs ); graph.setBorderVisible(false); graph.setPadding(new RectangleInsets(-5, -5, 0, -7)); graph.setBackgroundPaint(null); graph.setAntiAlias(true); plot = (XYPlot) graph.getPlot(); plot.setBackgroundAlpha(0.0f); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(true); renderer.setSeriesPaint(0, I_COLOR); renderer.setSeriesPaint(1, Q_COLOR); } // X-axis setup plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setVisible(true); plot.getDomainAxis().setRange(0, FMCUartClient.BLOCK_SIZE - 1); // Y-axis setup plot.getRangeAxis().setAutoRange(false); plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setUpperBound(Math.pow(2, 13)); plot.getRangeAxis().setLowerBound(-Math.pow(2, 13)); // setup chart panel chartPanel = new ChartPanel(graph, false); chartPanel.setMouseZoomable(false); chartPanel.setOpaque(false); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setDomainZoomable(true); // mouse wheel zooming chartPanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int clicks = e.getWheelRotation(); plot.getRangeAxis().setUpperBound(plot.getRangeAxis().getUpperBound() - (clicks * 100)); plot.getRangeAxis().setLowerBound(plot.getRangeAxis().getLowerBound() + (clicks * 100)); } }); }
From source file:edu.purdue.cc.bionet.ui.HeatMap.java
/** * The mouseWheelMoved method of the MouseWheelListener interface. * // ww w.java 2 s .c o m * @param e The event which triggered this action. */ public void mouseWheelMoved(MouseWheelEvent e) { this.scale((float) Math.pow(1.25, -e.getWheelRotation()), e.getPoint()); }
From source file:net.rptools.tokentool.ui.TokenCompositionPanel.java
public void mouseWheelMoved(MouseWheelEvent e) { if (tokenImage == null) { return;/*from ww w . ja v a 2 s . c o m*/ } double delta = SwingUtil.isControlDown(e) ? .1 : .01; double newScale = 0; if (e.getWheelRotation() > 0) { newScale = tokenScale - delta; } else { newScale = tokenScale + delta; } setScale(newScale); }
From source file:rod_design_compute.ShowPanel.java
private void formMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_formMouseWheelMoved // TODO add your handling code here: if (evt.getWheelRotation() > 0) { if (ratio >= 0.2) { ratio -= 0.1;// w w w.j a va 2 s.c o m radiusBase = (int) (radiusBaseDefault * ratio); lengthSlider = (int) (lengthSliderDefault * ratio); lengthBlock = (int) (lengthBlockDefault * ratio); repaint(); } } else if (evt.getWheelRotation() < 0) { ratio += 0.1; radiusBase = (int) (radiusBaseDefault * ratio); lengthSlider = (int) (lengthSliderDefault * ratio); lengthBlock = (int) (lengthBlockDefault * ratio); repaint(); } }
From source file:lu.lippmann.cdb.graph.GraphViewImpl.java
/** * {@inheritDoc}//from w w w . ja va 2 s . c om */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void init() { this.setBackground(new Color(235, 240, 245)); //this.setBackground(Color.WHITE); this.removeAll(); //normal init final CadralShapeRenderer vlasr = new CadralShapeRenderer(null, vv.getRenderContext()); // ----------------------------- // customize the render context // ----------------------------- final Transformer<CNode, String> vertexLabelTransformer = new Transformer<CNode, String>() { @Override public String transform(final CNode node) { final String tagString = (!node.getTags().isEmpty()) ? " [TAGGED!]" : ""; final FontMetrics fm = vv.getFontMetrics(vv.getFont()); final int textWidth = fm.stringWidth(node.getName()); final int tagWidth = fm.stringWidth(tagString); int nodeWidth = (int) ShapeFactory.createShape(node.getShape()).getBounds().getWidth(); final boolean hasTags = !node.getTags().isEmpty(); final int realTextWidth = textWidth + (hasTags ? tagWidth : 0); final String modifiedNodeName = node.getName() + (hasTags ? tagString : ""); if (realTextWidth > nodeWidth - 10) { int maxSubStringIndex = -1; for (int subStringIndex = node.getName().length(); subStringIndex >= 1; subStringIndex--) { String newString = node.getName().substring(0, subStringIndex) + "..." + tagString; if (fm.stringWidth(newString) < nodeWidth - 10) { maxSubStringIndex = subStringIndex; break; } } return node.getName().substring(0, maxSubStringIndex) + "..." + tagString; } else { return modifiedNodeName; } } }; vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); vv2.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); final Transformer<CNode, String> vertexTooltipTransformer = new Transformer<CNode, String>() { @Override public String transform(final CNode input) { if (!input.getTags().isEmpty()) { return buildTooltipFromTags(input.getName(), input.getTags()); } else { if (!input.getName().equals(vertexLabelTransformer.transform(input))) { return input.getName(); } else { return null; } } } }; vv.setVertexToolTipTransformer(vertexTooltipTransformer); vv2.setVertexToolTipTransformer(vertexTooltipTransformer); final Transformer<CEdge, String> edgeTooltipTransformer = new Transformer<CEdge, String>() { @Override public String transform(final CEdge input) { if (!input.getTags().isEmpty()) { return buildTooltipFromTags(input.getName(), input.getTags()); } else { return input.getName(); } } }; vv.setEdgeToolTipTransformer(edgeTooltipTransformer); vv2.setEdgeToolTipTransformer(edgeTooltipTransformer); vv.getRenderContext().setVertexFillPaintTransformer(new CadralVertexColorRenderer()); vv2.getRenderContext().setVertexFillPaintTransformer(new CadralVertexColorRenderer()); final CadralFontTransformer cadralFontTransformer = new CadralFontTransformer(); vv.getRenderContext().setVertexFontTransformer(cadralFontTransformer); vv.getRenderContext().setVertexShapeTransformer(vlasr); vv2.getRenderContext().setVertexShapeTransformer(vlasr); //VERTEX LABEL RENDERER vv.getRenderer().setVertexLabelRenderer(vlasr); vv2.getRenderer().setVertexLabelRenderer(vlasr); //FIXME : magic number vv.getRenderContext().setLabelOffset(16); vv2.getRenderContext().setLabelOffset(16); // custom edges final Transformer<CEdge, String> edgeLabelTransformer = new Transformer<CEdge, String>() { @Override public String transform(final CEdge input) { return input.getExpression() + (input.getTags().isEmpty() ? "" : " [TAGGED!]"); } }; vv.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer); vv2.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer); final Font myFont = new Font("Helvetica", 0, 12); //FAST EDGE LABEL RENDERER BUT NOT GOOD ENOUGH //sun.font.FontManager.getFont2D(myFont); vv.getRenderContext().setEdgeFontTransformer(cadralFontTransformer); vv2.getRenderContext().setEdgeFontTransformer(new ConstantTransformer(myFont)); vv.getRenderContext().setEdgeLabelClosenessTransformer(new ConstantTransformer(0.5)); vv2.getRenderContext().setEdgeLabelClosenessTransformer(new ConstantTransformer(0.5)); vv.getRenderContext().setEdgeDrawPaintTransformer(getDefaultEdgeDrawPaintTransformer()); vv2.getRenderContext().setEdgeDrawPaintTransformer(getDefaultEdgeDrawPaintTransformer()); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.BLUE, false)); vv2.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.BLUE, false)); vv.getRenderContext().setArrowDrawPaintTransformer( new PickableEdgePaintTransformer<CEdge>(vv.getPickedEdgeState(), Color.BLACK, Color.BLUE)); vv.getRenderContext().setArrowFillPaintTransformer( new PickableEdgePaintTransformer<CEdge>(vv.getPickedEdgeState(), Color.BLACK, Color.BLUE)); vv2.getRenderContext().setArrowDrawPaintTransformer( new PickableEdgePaintTransformer<CEdge>(vv.getPickedEdgeState(), Color.BLACK, Color.BLUE)); vv2.getRenderContext().setArrowFillPaintTransformer( new PickableEdgePaintTransformer<CEdge>(vv.getPickedEdgeState(), Color.BLACK, Color.BLUE)); //Manage Zoom vv.addMouseWheelListener(new MouseWheelListener() { private int zoom = 0; @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getWheelRotation() < 0) { zoom++; } else { zoom--; } if (zoom > 0) { if (zoom < 9) { double scale = 1 + zoom / 6.0; CadralShapeRenderer.setScale(scale); cadralFontTransformer.setScale(scale); } } else { CadralShapeRenderer.setScale(1); cadralFontTransformer.setScale(1); } } }); final Container panel = new JPanel(new BorderLayout()); final Container rightPanel = new JPanel(new GridLayout(2, 1)); panel.add(vv); final JPanel top = new JPanel(); final JButton button = new JButton("Rescale"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rescaleSatelliteView(); } }); top.add(button); rightPanel.add(top); rightPanel.add(vv2); panel.add(rightPanel, BorderLayout.EAST); setLayout(new BorderLayout()); add(metaInfosPanel, BorderLayout.NORTH); if (!USE_EXPERIMENTAL_SATELLITE_VIEW) { add(vv, BorderLayout.EAST); } else { add(panel, BorderLayout.EAST); } add(sharedLabel, BorderLayout.SOUTH); add(aboutPanel, BorderLayout.CENTER); validate(); repaint(); }