@Override public void mouseWheelMoved(MouseWheelEvent event) { if (graph_.mouseWheelMoved(event)) redrawGraphs(); }
@Override public void mouseDragged(MouseEvent event) { if (graph_.mouseDragged(event)) redrawGraphs(); }
@Override public void mousePressed(MouseEvent event) { graph_.mousePressed(event); }
@Override public void actionPerformed(ActionEvent arg0) { if (arg0.getActionCommand().equalsIgnoreCase("save")) { JFileChooser chooser = new JFileChooser(System.getProperty("user.dir")); int result = chooser.showSaveDialog(GraphFrame.this); if (result == JFileChooser.APPROVE_OPTION) { String path = chooser.getSelectedFile().getPath(); if (!path.endsWith(".graph")) path = path.concat(".graph"); graph_.printToFile(path); graph_.printToFile2(path + ".txt"); addFileNameToTitle(path); } } else if (arg0.getActionCommand().equalsIgnoreCase("load")) { JFileChooser chooser = new JFileChooser(System.getProperty("user.dir")); int result = chooser.showOpenDialog(GraphFrame.this); if (result == JFileChooser.APPROVE_OPTION) { graph_.loadFromFile2(chooser.getSelectedFile().getPath()); repaint(); } } else if (arg0.getActionCommand().equalsIgnoreCase("exit")) { System.exit(0); } else if (arg0.getActionCommand().equalsIgnoreCase("stepX")) { String value = JOptionPane.showInputDialog( GraphFrame.this, "Enter a value:", graph_.getGridStepX()); if (value != null && value.matches("\\d+")) graph_.setGridStepX(Integer.parseInt(value)); redrawGraphs(); } else if (arg0.getActionCommand().equalsIgnoreCase("stepY")) { String value = JOptionPane.showInputDialog( GraphFrame.this, "Enter a value:", graph_.getGridStepY()); if (value != null && value.matches("\\d+")) graph_.setGridStepY(Integer.parseInt(value)); redrawGraphs(); } else if (arg0.getActionCommand().equalsIgnoreCase("unitX")) { String value = JOptionPane.showInputDialog(GraphFrame.this, "Enter a value:", graph_.getUnitX()); if (value != null && value.matches("\\d+")) graph_.setUnitX(Integer.parseInt(value)); redrawGraphs(); } else if (arg0.getActionCommand().equalsIgnoreCase("unitY")) { String value = JOptionPane.showInputDialog(GraphFrame.this, "Enter a value:", graph_.getUnitY()); if (value != null && value.matches("\\d+")) graph_.setUnitY(Integer.parseInt(value)); redrawGraphs(); } else if (arg0.getActionCommand().equalsIgnoreCase("labelX")) { String value = JOptionPane.showInputDialog(GraphFrame.this, "Enter a value:", graph_.getLabelX()); if (value != null && value.length() > 0) graph_.setLabelX(value); redrawGraphs(); } else if (arg0.getActionCommand().equalsIgnoreCase("labelY")) { String value = JOptionPane.showInputDialog(GraphFrame.this, "Enter a value:", graph_.getLabelY()); if (value != null && value.length() > 0) graph_.setLabelY(value); redrawGraphs(); } }
public void loadGraphsFromFile(String filePath) { graph_.loadFromFile(filePath); addFileNameToTitle(filePath); }
private void redrawGraphs() { graph_.validate(); repaint(); }