List of usage examples for java.awt.event MouseWheelListener MouseWheelListener
MouseWheelListener
From source file:userinterface.properties.GUIGraphHandler.java
private void initComponents() { theTabs = new JTabbedPane() { @Override/*from w w w. j a v a2s . com*/ public String getTitleAt(int index) { try { TabClosePanel panel = (TabClosePanel) getTabComponentAt(index); return panel.getTitle(); } catch (Exception e) { return ""; } } @Override public String getToolTipTextAt(int index) { return ((TabClosePanel) getTabComponentAt(index)).getToolTipText(); } @Override public void setTitleAt(int index, String title) { if (((TabClosePanel) getTabComponentAt(index)) == null) { return; } ((TabClosePanel) getTabComponentAt(index)).setTitle(title); } @Override public void setIconAt(int index, Icon icon) { ((TabClosePanel) getTabComponentAt(index)).setIcon(icon); } @Override public void setToolTipTextAt(int index, String toolTipText) { ((TabClosePanel) getTabComponentAt(index)).setToolTip(toolTipText); } }; theTabs.addMouseListener(this); theTabs.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getPreciseWheelRotation() > 0.0) { if (theTabs.getSelectedIndex() != (theTabs.getTabCount() - 1)) theTabs.setSelectedIndex(theTabs.getSelectedIndex() + 1); } else { if (theTabs.getSelectedIndex() != 0) theTabs.setSelectedIndex(theTabs.getSelectedIndex() - 1); } } }); setLayout(new BorderLayout()); add(theTabs, BorderLayout.CENTER); graphOptions = new AbstractAction() { public void actionPerformed(ActionEvent e) { GraphOptions graphOptions = options.get(theTabs.getSelectedIndex()); graphOptions.setVisible(true); } }; graphOptions.putValue(Action.NAME, "Graph options"); graphOptions.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G)); graphOptions.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallOptions.png")); graphOptions.putValue(Action.LONG_DESCRIPTION, "Displays the options dialog for the graph."); zoomIn = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).zoomInBoth(-1, -1); else if (mgm instanceof Graph3D) { double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho(); ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho - 5); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomIn.putValue(Action.NAME, "In"); zoomIn.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); zoomIn.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerFwd.png")); zoomIn.putValue(Action.LONG_DESCRIPTION, "Zoom in on the graph."); zoomOut = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).zoomOutBoth(-1, -1); else if (mgm instanceof Graph3D) { double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho(); ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho + 5); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomOut.putValue(Action.NAME, "Out"); zoomOut.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_O)); zoomOut.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerRew.png")); zoomOut.putValue(Action.LONG_DESCRIPTION, "Zoom out of the graph."); zoomDefault = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).restoreAutoBounds(); else if (mgm instanceof Graph3D) { ((Graph3D) mgm).getChart3DPanel().zoomToFit(); ((Graph3D) mgm).getChart3DPanel().getDrawable() .setViewPoint(new ViewPoint3D(-Math.PI / 2, Math.PI * 1.124, 70.0, 0.0)); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomDefault.putValue(Action.NAME, "Default"); zoomDefault.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); zoomDefault.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerStart.png")); zoomDefault.putValue(Action.LONG_DESCRIPTION, "Set the default zoom for the graph."); importXML = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showOpenFileDialog(graFilter) != JFileChooser.APPROVE_OPTION) return; try { Graph mgm = Graph.load(plug.getChooserFile()); addGraph(mgm); } catch (GraphException ex) { plug.error("Could not import PRISM graph file:\n" + ex.getMessage()); } } }; importXML.putValue(Action.NAME, "PRISM graph (*.gra)"); importXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); importXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png")); importXML.putValue(Action.LONG_DESCRIPTION, "Imports a saved PRISM graph from a file."); addFunction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { plotNewFunction(); } }; addFunction.putValue(Action.NAME, "Plot function"); addFunction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); addFunction.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFunction.png")); addFunction.putValue(Action.LONG_DESCRIPTION, "Plots a new specified function on the current graph"); exportXML = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(graFilter) != JFileChooser.APPROVE_OPTION) return; Graph mgm = (Graph) models.get(theTabs.getSelectedIndex()); try { mgm.save(plug.getChooserFile()); } catch (PrismException ex) { plug.error("Could not export PRISM graph file:\n" + ex.getMessage()); } } }; exportXML.putValue(Action.NAME, "PRISM graph (*.gra)"); exportXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_X)); exportXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png")); exportXML.putValue(Action.LONG_DESCRIPTION, "Export graph as a PRISM graph file."); exportImageJPG = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model, GUIImageExportDialog.JPEG); saveImage(imageDialog); } }; exportImageJPG.putValue(Action.NAME, "JPEG Interchange Format (*.jpg, *.jpeg)"); exportImageJPG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_J)); exportImageJPG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png")); exportImageJPG.putValue(Action.LONG_DESCRIPTION, "Export graph as a JPEG file."); exportImagePNG = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model, GUIImageExportDialog.PNG); saveImage(imageDialog); } }; exportImagePNG.putValue(Action.NAME, "Portable Network Graphics (*.png)"); exportImagePNG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); exportImagePNG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png")); exportImagePNG.putValue(Action.LONG_DESCRIPTION, "Export graph as a Portable Network Graphics file."); exportPDF = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(pdfFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) Graph.exportToPDF(plug.getChooserFile(), ((ChartPanel) mgm).getChart()); else if (mgm instanceof Graph3D) { Graph3D.exportToPDF(plug.getChooserFile(), ((Graph3D) mgm).getChart3DPanel()); } } }; exportPDF.putValue(Action.NAME, "Portable document format (*.pdf)"); exportPDF.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); exportPDF.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png")); exportPDF.putValue(Action.LONG_DESCRIPTION, "Export the graph as a Portable document format file."); exportImageEPS = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); if (model instanceof ChartPanel) { GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), (ChartPanel) model, GUIImageExportDialog.EPS); saveImage(imageDialog); } } }; exportImageEPS.putValue(Action.NAME, "Encapsulated PostScript (*.eps)"); exportImageEPS.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E)); exportImageEPS.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png")); exportImageEPS.putValue(Action.LONG_DESCRIPTION, "Export graph as an Encapsulated PostScript file."); exportMatlab = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(matlabFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof Graph) { try { ((Graph) mgm).exportToMatlab(plug.getChooserFile()); } catch (IOException ex) { plug.error("Could not export Matlab file:\n" + ex.getMessage()); } } else if (mgm instanceof Graph3D) { try { ((Graph3D) mgm).exportToMatlab(plug.getChooserFile()); } catch (IOException e1) { plug.error("Could not export Matlab file:\n" + e1.getMessage()); e1.printStackTrace(); } } } }; exportMatlab.putValue(Action.NAME, "Matlab file (*.m)"); exportMatlab.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_M)); exportMatlab.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileMatlab.png")); exportMatlab.putValue(Action.LONG_DESCRIPTION, "Export graph as a Matlab file."); exportGnuplot = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(gnuplotFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) { try { if (mgm instanceof Graph && !(mgm instanceof ParametricGraph)) { ((Graph) mgm).exportToGnuplot(plug.getChooserFile()); } else if (mgm instanceof ParametricGraph) { ((ParametricGraph) mgm).exportToGnuplot(plug.getChooserFile()); } else if (mgm instanceof Histogram) { ((Histogram) mgm).exportToGnuplot(plug.getChooserFile()); } } catch (IOException ex) { plug.error("Could not export Gnuplot file:\n" + ex.getMessage()); } } else if (mgm instanceof Graph3D) { try { ((Graph3D) mgm).exportToGnuplot(plug.getChooserFile()); } catch (IOException ex) { plug.error("Could not export Gnuplot file:\n" + ex.getMessage()); ex.printStackTrace(); } } } }; exportGnuplot.putValue(Action.NAME, "GNU Plot file(*.gnuplot)"); exportGnuplot.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G)); exportGnuplot.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallgnuplot.png")); exportGnuplot.putValue(Action.LONG_DESCRIPTION, "Export graph as a GNU plot file."); printGraph = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel graph = models.get(theTabs.getSelectedIndex()); if (graph instanceof ChartPanel) { if (graph instanceof Graph) { if (!((Graph) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) { if (plug.questionYesNo( "Your graph has a coloured background, this background will show up on the \n" + "printout. Would you like to make the current background colour white?") == 0) { ((Graph) graph).getDisplaySettings().setBackgroundColor(Color.white); } } } else if (graph instanceof Histogram) { if (!((Histogram) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) { if (plug.questionYesNo( "Your graph has a coloured background, this background will show up on the \n" + "printout. Would you like to make the current background colour white?") == 0) { ((Histogram) graph).getDisplaySettings().setBackgroundColor(Color.white); } } } ((ChartPanel) graph).createChartPrintJob(); } if (graph instanceof Graph3D) { ((Graph3D) graph).createPrintJob(); } } }; printGraph.putValue(Action.NAME, "Print graph"); printGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); printGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPrint.png")); printGraph.putValue(Action.LONG_DESCRIPTION, "Print the graph to a printer or file"); deleteGraph = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel graph = models.get(theTabs.getSelectedIndex()); models.remove(theTabs.getSelectedIndex()); options.remove(theTabs.getSelectedIndex()); theTabs.remove(graph); } }; deleteGraph.putValue(Action.NAME, "Delete graph"); deleteGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); deleteGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png")); deleteGraph.putValue(Action.LONG_DESCRIPTION, "Deletes the graph."); zoomMenu = new JMenu("Zoom"); zoomMenu.setMnemonic('Z'); zoomMenu.setIcon(GUIPrism.getIconFromImage("smallView.png")); zoomMenu.add(zoomIn); zoomMenu.add(zoomOut); zoomMenu.add(zoomDefault); exportMenu = new JMenu("Export graph"); exportMenu.setMnemonic('E'); exportMenu.setIcon(GUIPrism.getIconFromImage("smallExport.png")); exportMenu.add(exportXML); exportMenu.add(exportImagePNG); exportMenu.add(exportPDF); exportMenu.add(exportImageEPS); exportMenu.add(exportImageJPG); exportMenu.add(exportMatlab); exportMenu.add(exportGnuplot); importMenu = new JMenu("Import graph"); importMenu.setMnemonic('I'); importMenu.setIcon(GUIPrism.getIconFromImage("smallImport.png")); importMenu.add(importXML); graphMenu.add(graphOptions); graphMenu.add(zoomMenu); graphMenu.addSeparator(); graphMenu.add(printGraph); graphMenu.add(deleteGraph); graphMenu.addSeparator(); graphMenu.add(exportMenu); graphMenu.add(importMenu); graphMenu.add(addFunction); /* Tab context menu */ backMenu.add(importXML); }
From source file:com.projity.pm.graphic.views.GanttView.java
public void init(ReferenceNodeModelCache cache, NodeModel model, CoordinatesConverter coord) { this.coord = coord; this.cache = NodeModelCacheFactory.getInstance().createFilteredCache((ReferenceNodeModelCache) cache, getViewName(), null);// w w w . j a v a2 s . c o m fieldContext = new FieldContext(); fieldContext.setLeftAssociation(true); /*cellStyle=new CellStyle(){ CellFormat cellProperties=new CellFormat(); public CellFormat getCellProperties(GraphicNode node){ cellProperties.setBold(node.isSummary()); cellProperties.setItalic(node.isAssignment()); //cellProperties.setBackground((node.isAssignment())?"NORMAL_LIGHT_YELLOW":"NORMAL_YELLOW"); cellProperties.setCompositeIcon(node.isComposite()); return cellProperties; } };*/ super.init(); updateHeight(project); updateSize(); //sync the height of spreadsheet and gantt leftScrollPane.getViewport().addChangeListener(new ChangeListener() { private Dimension olddl = null; public void stateChanged(ChangeEvent e) { Dimension dl = leftScrollPane.getViewport().getViewSize(); if (dl.equals(olddl)) return; olddl = dl; // Dimension dr=rightScrollPane.getViewport().getViewSize(); // ((Gantt)rightScrollPane.getViewport().getView()).setPreferredSize(new Dimension((int)dr.getWidth(),(int)dl.getHeight())); // rightScrollPane.getViewport().revalidate(); ((Gantt) rightScrollPane.getViewport().getView()).setPreferredSize( new Dimension(rightScrollPane.getViewport().getViewSize().width, dl.height)); } }); //TODO automatic scrolling to add as an option // spreadSheet.getRowHeader().getSelectionModel().addListSelectionListener(new ListSelectionListener(){ // public void valueChanged(ListSelectionEvent e) { // if (!e.getValueIsAdjusting()&&spreadSheet.getRowHeader().getSelectedRowCount()==1){ // List impls=spreadSheet.getSelectedNodesImpl(); // if (impls.size()!=1) return; // Object impl=impls.get(0); // if (!(impl instanceof HasStartAndEnd)) return; // HasStartAndEnd interval=(HasStartAndEnd)impl; // gantt.scrollToTask(interval, true); // } // } // }); MouseWheelListener scrollManager = new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { if (0 != (e.getModifiers() & InputEvent.ALT_MASK)) { Component c = e.getComponent(); while ((c != null) && !(c instanceof JViewport)) c = c.getParent(); JViewport vp = (JViewport) c; Point p = vp.getViewPosition(); int newX = p.x + e.getUnitsToScroll() * getWidth() / 20; if (newX > 0) { p.x = newX; } else { p.x = 0; } vp.setViewPosition(p); } else if (0 != (e.getModifiers() & InputEvent.CTRL_MASK)) { zoom(-e.getUnitsToScroll() / 3); } else { //Vertical scroll allways on gantt chart JViewport vp = (JViewport) gantt.getParent(); Point p = vp.getViewPosition(); int newY = p.y + e.getUnitsToScroll() * gantt.getRowHeight(); if (newY > 0) { p.y = newY; } else { p.y = 0; } vp.setViewPosition(p); } } }; leftScrollPane.getViewport().addMouseWheelListener(scrollManager); gantt.addMouseWheelListener(scrollManager); cache.update(); //Call this last to be sure everything is initialized //gantt.insertCacheData(); //useless? }
From source file:base.BasePlayer.BedCanvas.java
BedCanvas(int width, int height) { this.width = width; this.height = height; bufImage = MethodLibrary.toCompatibleImage(new BufferedImage((int) Main.screenSize.getWidth(), (int) Main.screenSize.getHeight(), BufferedImage.TYPE_INT_ARGB)); buf = (Graphics2D) bufImage.getGraphics(); // buf.setRenderingHints(Draw.rh); nodeImage = MethodLibrary.toCompatibleImage(new BufferedImage((int) Main.screenSize.getWidth(), (int) Main.screenSize.getHeight(), BufferedImage.TYPE_INT_ARGB)); nodebuf = (Graphics2D) nodeImage.getGraphics(); // nodebuf.setRenderingHints(Draw.rh); backupComposite = nodebuf.getComposite(); buf.setFont(Draw.defaultFont);//from w w w . j a va 2s. co m //nodebuf.setFont(Draw.defaultFont); addMouseListener(this); addKeyListener(this); addMouseMotionListener(this); addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent mwe) { bedTrack.get(hoverIndex).mouseWheel -= mwe.getWheelRotation(); if (bedTrack.get(hoverIndex).mouseWheel > 0) { bedTrack.get(hoverIndex).mouseWheel = 0; } repaint(); } }); }
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; }/*w ww . j av a 2 s. c o 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 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; }/*from w w w . ja v a 2 s.c o 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:com.epiq.bitshark.ui.FrequencyDomainPanel.java
/** * Initialize the graph/*from w w w.j a v a 2 s . c om*/ */ private void initGraph() { this.series = new BasicSeries("FFT"); XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart graph = ChartFactory.createXYLineChart(null, // 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.setBackgroundImageAlpha(0.0f); graph.setAntiAlias(true); plot = (XYPlot) graph.getPlot(); powerAxis = new PowerAxis(); plot.setRangeAxis(powerAxis); frequencyAxis = new FrequencyAxis(); frequencyAxis.setTickLabelInsets(new RectangleInsets(10, 0, 0, 0)); plot.setDomainAxis(frequencyAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(true); renderer.setSeriesPaint(0, Common.EPIQ_GREEN); renderer.setSeriesStroke(0, new BasicStroke(1.0f)); } plot.setBackgroundAlpha(0.0f); plot.setBackgroundPaint(null); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); // X-axis setup plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setVisible(true); plot.getDomainAxis().setRange(0, FMCUartClient.BLOCK_SIZE - 1); plot.setDomainCrosshairVisible(false); plot.setDomainCrosshairPaint(new Color(46, 46, 46)); // Y-axis setup plot.getRangeAxis().setAutoRange(false); plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setRange(-50, 70); plot.setRangeCrosshairVisible(false); markerAnnotation.setVisible(false); plot.addAnnotation(markerAnnotation); plot.addAnnotation(markerTextAnnotation); this.markerTitle.setFont(new Font("Tahoma", Font.BOLD, 12)); this.markerTitle.setFrame(new BlockBorder(new Color(46, 46, 46))); this.markerTitle.setBackgroundPaint(new Color(200, 200, 255, 100)); this.markerTitle.setText(""); this.markerTitle.setPadding(5, 15, 5, 15); this.markerTitle.setExpandToFitSpace(false); this.markerTitle.setBounds(new Rectangle2D.Double(0, 0, 100, 30)); chartPanel = new ChartPanel(graph, false); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setMouseZoomable(true); chartPanel.setOpaque(false); chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent event) { markerLocked = !markerLocked; } @Override public void chartMouseMoved(ChartMouseEvent event) { updateMouseMarker(event); } }); chartPanel.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { if (!markerLocked) { markerAnnotation.setVisible(false); plot.setDomainCrosshairVisible(false); markerTitle.setVisible(false); markerTitle.setText(""); } } }); chartPanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int clicks = e.getWheelRotation(); plot.getRangeAxis().setUpperBound(plot.getRangeAxis().getUpperBound() + clicks); plot.getRangeAxis().setLowerBound(plot.getRangeAxis().getLowerBound() + clicks); } }); }
From source file:lu.lippmann.cdb.graph.GraphViewImpl.java
/** * {@inheritDoc}//from w w w . j a va 2 s .com */ @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(); }
From source file:de.tor.tribes.ui.panels.MinimapPanel.java
/** * Creates new form MinimapPanel/*ww w . ja va 2 s. c om*/ */ MinimapPanel() { initComponents(); setSize(300, 300); mMinimapListeners = new LinkedList<>(); mToolChangeListeners = new LinkedList<>(); setCursor(ImageManager.getCursor(iCurrentCursor)); mScreenshotPanel = new ScreenshotPanel(); minimapButtons.put(ID_MINIMAP, new Rectangle(2, 2, 26, 26)); minimapButtons.put(ID_ALLY_CHART, new Rectangle(30, 2, 26, 26)); minimapButtons.put(ID_TRIBE_CHART, new Rectangle(60, 2, 26, 26)); try { minimapIcons.put(ID_MINIMAP, ImageIO.read(new File("./graphics/icons/minimap.png"))); minimapIcons.put(ID_ALLY_CHART, ImageIO.read(new File("./graphics/icons/ally_chart.png"))); minimapIcons.put(ID_TRIBE_CHART, ImageIO.read(new File("./graphics/icons/tribe_chart.png"))); } catch (Exception ignored) { } jPanel1.add(mScreenshotPanel); rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension()); zoomed = false; MarkerManager.getSingleton().addManagerListener(this); TagManager.getSingleton().addManagerListener(this); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); if (!GlobalOptions.isMinimal()) { MinimapRepaintThread.getSingleton().start(); } addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (!showControls && e.getButton() != MouseEvent.BUTTON1) { //show controls Point p = e.getPoint(); p.translate(-5, -5); showControls(p); return; } if (!showControls && iCurrentView == ID_MINIMAP) { Point p = mousePosToMapPosition(e.getX(), e.getY()); DSWorkbenchMainFrame.getSingleton().centerPosition(p.getX(), p.getY()); MapPanel.getSingleton().getMapRenderer().initiateRedraw(MapRenderer.ALL_LAYERS); if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().toFront(); } } else { if (minimapButtons.get(ID_MINIMAP).contains(e.getPoint())) { iCurrentView = ID_MINIMAP; mBuffer = null; showControls = false; MinimapRepaintThread.getSingleton().update(); } else if (minimapButtons.get(ID_ALLY_CHART).contains(e.getPoint())) { iCurrentView = ID_ALLY_CHART; lastHash = 0; showControls = false; updateComplete(); } else if (minimapButtons.get(ID_TRIBE_CHART).contains(e.getPoint())) { iCurrentView = ID_TRIBE_CHART; lastHash = 0; showControls = false; updateComplete(); } } } @Override public void mousePressed(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } if (iCurrentCursor == ImageManager.CURSOR_SHOT || iCurrentCursor == ImageManager.CURSOR_ZOOM) { iXDown = e.getX(); iYDown = e.getY(); } } @Override public void mouseReleased(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } if (rDrag == null) { return; } if (iCurrentCursor == ImageManager.CURSOR_SHOT) { try { BufferedImage i = MinimapRepaintThread.getSingleton().getImage(); double widthFactor = ((double) ServerSettings.getSingleton().getMapDimension().width) / getWidth(); double heightFactor = ((double) ServerSettings.getSingleton().getMapDimension().height) / getHeight(); int x = (int) Math.rint(widthFactor * rDrag.getX()); int y = (int) Math.rint(heightFactor * rDrag.getY()); int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX())); int h = (int) Math.rint(heightFactor * (rDrag.getHeight() - rDrag.getY())); BufferedImage sub = i.getSubimage(x, y, w, h); mScreenshotPanel.setBuffer(sub); jPanel1.setSize(mScreenshotPanel.getSize()); jPanel1.setPreferredSize(mScreenshotPanel.getSize()); jPanel1.setMinimumSize(mScreenshotPanel.getSize()); jPanel1.setMaximumSize(mScreenshotPanel.getSize()); jScreenshotPreview.pack(); jScreenshotControl.pack(); jScreenshotPreview.setVisible(true); jScreenshotControl.setVisible(true); } catch (Exception ie) { logger.error("Failed to initialize mapshot", ie); } } else if (iCurrentCursor == ImageManager.CURSOR_ZOOM) { if (!zoomed) { Rectangle mapDim = ServerSettings.getSingleton().getMapDimension(); double widthFactor = ((double) mapDim.width) / getWidth(); double heightFactor = ((double) mapDim.height) / getHeight(); int x = (int) Math.rint(widthFactor * rDrag.getX() + mapDim.getMinX()); int y = (int) Math.rint(heightFactor * rDrag.getY() + mapDim.getMinY()); int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX())); if (w >= 10) { rVisiblePart = new Rectangle(x, y, w, w); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); redraw(); zoomed = true; } } else { rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension()); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); redraw(); zoomed = false; } MinimapZoomFrame.getSingleton().setVisible(false); } iXDown = 0; iYDown = 0; rDrag = null; } @Override public void mouseEntered(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } switch (iCurrentCursor) { case ImageManager.CURSOR_ZOOM: { MinimapZoomFrame.getSingleton().setVisible(true); } } } @Override public void mouseExited(MouseEvent e) { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } iXDown = 0; iYDown = 0; rDrag = null; } }); addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } switch (iCurrentCursor) { case ImageManager.CURSOR_MOVE: { Point p = mousePosToMapPosition(e.getX(), e.getY()); DSWorkbenchMainFrame.getSingleton().centerPosition(p.x, p.y); rDrag = null; break; } case ImageManager.CURSOR_SHOT: { rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY()); break; } case ImageManager.CURSOR_ZOOM: { rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY()); break; } } } @Override public void mouseMoved(MouseEvent e) { if (iCurrentView == ID_MINIMAP) { switch (iCurrentCursor) { case ImageManager.CURSOR_ZOOM: { if (!MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(true); } int mapWidth = (int) ServerSettings.getSingleton().getMapDimension().getWidth(); int mapHeight = (int) ServerSettings.getSingleton().getMapDimension().getHeight(); int x = (int) Math.rint((double) mapWidth / (double) getWidth() * (double) e.getX()); int y = (int) Math.rint((double) mapHeight / (double) getHeight() * (double) e.getY()); MinimapZoomFrame.getSingleton().updatePosition(x, y); break; } default: { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } } } } Point location = minimapButtons.get(ID_MINIMAP).getLocation(); location.translate(-2, -2); if (!new Rectangle(location.x, location.y, 88, 30).contains(e.getPoint())) { //hide controls showControls = false; repaint(); } } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (iCurrentView != ID_MINIMAP) { return; } iCurrentCursor += e.getWheelRotation(); if (iCurrentCursor == ImageManager.CURSOR_DEFAULT + e.getWheelRotation()) { if (e.getWheelRotation() < 0) { iCurrentCursor = ImageManager.CURSOR_SHOT; } else { iCurrentCursor = ImageManager.CURSOR_MOVE; } } else if (iCurrentCursor < ImageManager.CURSOR_MOVE) { iCurrentCursor = ImageManager.CURSOR_DEFAULT; } else if (iCurrentCursor > ImageManager.CURSOR_SHOT) { iCurrentCursor = ImageManager.CURSOR_DEFAULT; } if (iCurrentCursor != ImageManager.CURSOR_ZOOM) { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } } else { MinimapZoomFrame.getSingleton().setVisible(true); } setCurrentCursor(iCurrentCursor); } }); }
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; }/* w w w . j a va 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.fhcrc.cpl.viewer.gui.MRMDialog.java
private void transitionListInitializations() { listTransition = new JList(); listTransition.setCellRenderer(new coloredMRMListRenderer()); listTransition.setModel(new DefaultListModel()); listTransition.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _tlsl = new transitionListSelectionListener(); listTransition.addListSelectionListener(_tlsl); listTransition.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent event) { int move = event.getWheelRotation(); int curIndex = listTransition.getSelectedIndex(); int newIndex = curIndex; if (move > 0) { newIndex = Math.min(curIndex + move, listTransition.getModel().getSize()); listTransition.setSelectedIndex(newIndex); }/*from w w w. j a v a2 s . c o m*/ if (move < 0) { newIndex = Math.max(curIndex + move, 0); listTransition.setSelectedIndex(newIndex); } listTransition.ensureIndexIsVisible(newIndex); } }); for (MRMTransition curTran : _mrmTransitions) ((DefaultListModel) listTransition.getModel()).addElement(curTran); listTransition.setVisible(true); listScrollPane.getViewport().setView(listTransition); listScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); listScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { if (!ae.getValueIsAdjusting()) { listTransition.repaint(); } } }); }