List of usage examples for javax.swing JSlider addChangeListener
public void addChangeListener(ChangeListener l)
From source file:AtomPanel.java
private void commonInit() { //initial time series plots initJFreeChart();/*from w w w . j a v a 2 s. c om*/ startFlag = false; //create control panel // JPanel panel=new JPanel(new GridLayout(1,2)); //add control buttons to control panel /* startButton=new JButton("Start"); startButton.addActionListener(this); pauseButton=new JButton("Pause"); pauseButton.addActionListener(this); stopButton=new JButton("Stop"); stopButton.addActionListener(this); panel.add(startButton); panel.add(pauseButton); panel.add(stopButton); */ JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); //Create the slider JSlider faRateSlider = new JSlider(JSlider.HORIZONTAL, L_MIN, L_MAX, L_INIT); faRateSlider.setName("faRate"); faRateSlider.addChangeListener(this); faRateSlider.setMajorTickSpacing(30); faRateSlider.setPaintTicks(true); //Create the label table Hashtable labelTable = new Hashtable(); labelTable.put(new Integer(L_MIN), new JLabel("0.1%")); labelTable.put(new Integer((L_MIN + L_MAX) / 2), new JLabel(" False Alarm Rate")); labelTable.put(new Integer(L_MAX), new JLabel("1%")); faRateSlider.setLabelTable(labelTable); faRateSlider.setPaintLabels(true); panel.add(faRateSlider); // window size slider JSlider wdSzSlider = new JSlider(JSlider.HORIZONTAL, L_MIN, L_MAX, WDL_INIT); wdSzSlider.setName("wdSz"); wdSzSlider.addChangeListener(this); wdSzSlider.setMajorTickSpacing(30); wdSzSlider.setPaintTicks(true); //Create the label table Hashtable wdTable = new Hashtable(); wdTable.put(new Integer(L_MIN), new JLabel("20")); wdTable.put(new Integer((L_MIN + L_MAX) / 2), new JLabel(" Window Size")); wdTable.put(new Integer(L_MAX), new JLabel("200")); wdSzSlider.setLabelTable(wdTable); wdSzSlider.setPaintLabels(true); panel.add(wdSzSlider); if (AtomUtils.PCAType.pcaTrack == this.pcaType) { // new: tracking delta bar JSlider deltaSlider = new JSlider(JSlider.HORIZONTAL, L_MIN, L_MAX, L_INIT); deltaSlider.setName("delta"); deltaSlider.addChangeListener(this); deltaSlider.setMajorTickSpacing(30); deltaSlider.setPaintTicks(true); //Create the label table labelTable = new Hashtable(); labelTable.put(new Integer(L_MIN), new JLabel("0%")); labelTable.put(new Integer((L_MIN + L_MAX) / 2), new JLabel(" Tracking Threshold")); labelTable.put(new Integer(L_MAX), new JLabel("20%")); deltaSlider.setLabelTable(labelTable); deltaSlider.setPaintLabels(true); panel.add(deltaSlider); // tracking saving label trackSaveLabel = new JLabel(); trackSaveLabel.setText("Saved/Total:0/0"); panel.add(trackSaveLabel); } if (AtomUtils.PCAType.pcaTrackAdjust == this.pcaType) { JSlider devSlider = new JSlider(JSlider.HORIZONTAL, L_MIN, L_MAX, L_INIT); devSlider.setName("devbnd"); devSlider.addChangeListener(this); devSlider.setMajorTickSpacing(30); devSlider.setPaintTicks(true); //Create the label table labelTable = new Hashtable(); labelTable.put(new Integer(L_MIN), new JLabel("0%")); labelTable.put(new Integer((L_MIN + L_MAX) / 2), new JLabel(" Deviation Bound")); labelTable.put(new Integer(L_MAX), new JLabel("1%")); devSlider.setLabelTable(labelTable); devSlider.setPaintLabels(true); panel.add(devSlider); // tracking saving label trackSaveLabel = new JLabel(); trackSaveLabel.setText("Saved/Total:0/0"); panel.add(trackSaveLabel); } add(panel, BorderLayout.SOUTH); }
From source file:SoundPlayer.java
void addMidiControls() { // Add a slider to control the tempo final JSlider tempo = new JSlider(50, 200); tempo.setValue((int) (sequencer.getTempoFactor() * 100)); tempo.setBorder(new TitledBorder("Tempo Adjustment (%)")); java.util.Hashtable labels = new java.util.Hashtable(); labels.put(new Integer(50), new JLabel("50%")); labels.put(new Integer(100), new JLabel("100%")); labels.put(new Integer(200), new JLabel("200%")); tempo.setLabelTable(labels);/*from w ww . j a v a2 s . co m*/ tempo.setPaintLabels(true); // The event listener actually changes the tmpo tempo.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sequencer.setTempoFactor(tempo.getValue() / 100.0f); } }); this.add(tempo); // Create rows of solo and checkboxes for each track Track[] tracks = sequence.getTracks(); for (int i = 0; i < tracks.length; i++) { final int tracknum = i; // Two checkboxes per track final JCheckBox solo = new JCheckBox("solo"); final JCheckBox mute = new JCheckBox("mute"); // The listeners solo or mute the track solo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sequencer.setTrackSolo(tracknum, solo.isSelected()); } }); mute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sequencer.setTrackMute(tracknum, mute.isSelected()); } }); // Build up a row Box box = Box.createHorizontalBox(); box.add(new JLabel("Track " + tracknum)); box.add(Box.createHorizontalStrut(10)); box.add(solo); box.add(Box.createHorizontalStrut(10)); box.add(mute); box.add(Box.createHorizontalGlue()); // And add it to this component this.add(box); } }
From source file:SoundPlayer.java
JSlider createSlider(final FloatControl c) { if (c == null) return null; final JSlider s = new JSlider(0, 1000); final float min = c.getMinimum(); final float max = c.getMaximum(); final float width = max - min; float fval = c.getValue(); s.setValue((int) ((fval - min) / width * 1000)); java.util.Hashtable labels = new java.util.Hashtable(3); labels.put(new Integer(0), new JLabel(c.getMinLabel())); labels.put(new Integer(500), new JLabel(c.getMidLabel())); labels.put(new Integer(1000), new JLabel(c.getMaxLabel())); s.setLabelTable(labels);//ww w . j a va 2 s. co m s.setPaintLabels(true); s.setBorder(new TitledBorder(c.getType().toString() + " " + c.getUnits())); s.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { int i = s.getValue(); float f = min + (i * width / 1000.0f); c.setValue(f); } }); return s; }
From source file:projects.tgas.exec.HrDiagram.java
/** * Main constructor.//from www.j av a 2s . com */ public HrDiagram() { tgasStars = TgasUtils.loadTgasCatalogue(); method = METHOD.NAIVE; fMax = 1.0; final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values()); methodComboBox.setSelectedItem(method); methodComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { method = (METHOD) methodComboBox.getSelectedItem(); updateChart(); } }); final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f"); fSlider.setValue((int) Math.rint(100.0 * fMax / 2.0)); final JLabel fLabel = new JLabel(getFLabel()); // Create a change listener fot these ChangeListener cl = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (source == fSlider) { // Compute fractional parallax error from slider position double newF = (2.0 * source.getValue() / 100.0); fMax = newF; fLabel.setText(getFLabel()); } updateChart(); } }; fSlider.addChangeListener(cl); // Add a bit of padding to space things out fSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); // Present controls below the HR diagram JPanel controls = new JPanel(new GridLayout(2, 2)); controls.add(new JLabel("Distance estimation method:")); controls.add(methodComboBox); controls.add(fLabel); controls.add(fSlider); // Initialise the ChartPanel updateChart(); // Build the panel contents setLayout(new BorderLayout()); add(hrDiagPanel, BorderLayout.CENTER); add(controls, BorderLayout.SOUTH); }
From source file:projects.hip.exec.HrDiagram.java
/** * Main constructor.// w ww . j av a 2 s. c o m */ public HrDiagram() { hipStars = HipUtils.loadHipCatalogue(); method = METHOD.NAIVE; fMax = 1.0; final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values()); methodComboBox.setSelectedItem(method); methodComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { method = (METHOD) methodComboBox.getSelectedItem(); updateChart(); } }); final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f"); fSlider.setValue((int) Math.rint(100.0 * fMax / 2.0)); final JLabel fLabel = new JLabel(getFLabel()); // Create a change listener fot these ChangeListener cl = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (source == fSlider) { // Compute fractional parallax error from slider position double newF = (2.0 * source.getValue() / 100.0); fMax = newF; fLabel.setText(getFLabel()); } updateChart(); } }; fSlider.addChangeListener(cl); // Add a bit of padding to space things out fSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); // Present controls below the HR diagram JPanel controls = new JPanel(new GridLayout(2, 2)); controls.add(new JLabel("Distance estimation method:")); controls.add(methodComboBox); controls.add(fLabel); controls.add(fSlider); // Initialise the ChartPanel updateChart(); // Build the panel contents setLayout(new BorderLayout()); add(hrDiagPanel, BorderLayout.WEST); add(dDistPanel, BorderLayout.EAST); add(controls, BorderLayout.SOUTH); }
From source file:projects.upc.exec.HrDiagram.java
/** * Main constructor.//from ww w . jav a 2 s .co m */ public HrDiagram() { List<UpcStar> upcStars = UpcUtils.loadUpcCatalogue(); List<UpcStar> hipStars = UpcUtils.getHipparcosSubset(upcStars); List<UpcStar> unmatchedStars = UpcUtils.getUnmatchedSubset(upcStars); upcStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(upcStars); hipStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(hipStars); unmatchedStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(unmatchedStars); logger.info("Loaded " + upcStarCrossMatches.size() + " UpcStars with SSA cross matches"); logger.info("Loaded " + hipStarCrossMatches.size() + " UpcStars with Hipparcos and SSA cross matches"); logger.info("Loaded " + unmatchedStarCrossMatches.size() + " UpcStars with no parallax cross-match, and with SSA cross matches"); starsToPlot = upcStarCrossMatches; useHip = false; method = METHOD.NAIVE; fMax = 1.0; final JCheckBox plotAllCheckBox = new JCheckBox("Plot all UPC stars: ", true); plotAllCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (plotAllCheckBox.isSelected()) { starsToPlot = upcStarCrossMatches; updateChart(); } } }); final JCheckBox plotHipCheckBox = new JCheckBox("Plot Hipparcos stars only: ", false); plotHipCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (plotHipCheckBox.isSelected()) { starsToPlot = hipStarCrossMatches; updateChart(); } } }); final JCheckBox plotUnmatchedCheckBox = new JCheckBox("Plot all stars with no external match: ", false); plotUnmatchedCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (plotUnmatchedCheckBox.isSelected()) { starsToPlot = unmatchedStarCrossMatches; updateChart(); } } }); final ButtonGroup bg = new ButtonGroup(); bg.add(plotHipCheckBox); bg.add(plotAllCheckBox); bg.add(plotUnmatchedCheckBox); JCheckBox useHipCheckBox = new JCheckBox("Use Hipparcos parallaxes when available", useHip); useHipCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { useHip = !useHip; updateChart(); } }); final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values()); methodComboBox.setSelectedItem(method); methodComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { method = (METHOD) methodComboBox.getSelectedItem(); updateChart(); } }); final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f"); fSlider.setValue((int) Math.rint(100.0 * fMax)); final JLabel fLabel = new JLabel(getFLabel()); // Create a change listener fot these ChangeListener cl = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (source == fSlider) { // Compute fractional parallax error from slider position double newF = (2.0 * source.getValue() / 100.0); fMax = newF; fLabel.setText(getFLabel()); } updateChart(); } }; fSlider.addChangeListener(cl); // Add a bit of padding to space things out fSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); // Present controls below the HR diagram JPanel controls = new JPanel(new GridLayout(3, 3)); controls.add(plotAllCheckBox); controls.add(plotHipCheckBox); controls.add(plotUnmatchedCheckBox); controls.add(new JLabel("Distance estimation method:")); controls.add(methodComboBox); controls.add(useHipCheckBox); controls.add(fLabel); controls.add(fSlider); // Initialise the ChartPanel updateChart(); // Build the panel contents setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); add(controls, BorderLayout.SOUTH); }
From source file:fr.free.hd.servers.gui.FaceView.java
private JPanel createMouth() { JPanel panel = new JPanel(new GridLayout(3, 0)); final JSlider slider = new JSlider(); final JSlider sliderX = new JSlider(); final JSlider sliderY = new JSlider(); slider.setMinimum(0);/*from w ww . j a v a 2s. c om*/ slider.setMaximum(1000); slider.setMajorTickSpacing(100); slider.setPaintLabels(true); slider.setPaintTicks(true); slider.setPaintTrack(true); sliderX.setMinimum(-1000); sliderX.setMaximum(1000); sliderX.setMajorTickSpacing(100); sliderX.setPaintLabels(true); sliderX.setPaintTicks(true); sliderX.setPaintTrack(true); sliderY.setMinimum(-1000); sliderY.setMaximum(1000); sliderY.setMajorTickSpacing(100); sliderY.setPaintLabels(true); sliderY.setPaintTicks(true); sliderY.setPaintTrack(true); sliderX.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { face.setMouthXPercent(sliderX.getValue()); updateLabel(); } }); sliderY.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { face.setMouthYPercent(sliderY.getValue()); updateLabel(); } }); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { face.setMouthRatio(slider.getValue()); updateLabel(); } }); panel.add(slider); panel.add(sliderX); panel.add(sliderY); return panel; }
From source file:com.imag.nespros.gui.plugin.GraphEditor.java
/** * create an instance of a simple graph with popup controls to create a * graph./* w w w .j a v a2 s . co m*/ * */ private GraphEditor(Simulation s) { simu = s; try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { Logger.getLogger(GraphEditor.class.getName()).log(Level.SEVERE, null, ex); } // create a simple graph for the demo graph = Topology.getInstance().getGraph(); this.layout = new StaticLayout<Device, ComLink>(graph, new Transformer<Device, Point2D>() { @Override public Point2D transform(Device v) { Point2D p = new Point2D.Double(v.getX(), v.getY()); return p; } }, new Dimension(600, 600)); vv = new VisualizationViewer<Device, ComLink>(layout); vv.setBackground(Color.white); final Transformer<Device, String> vertexLabelTransformer = new Transformer<Device, String>() { @Override public String transform(Device d) { return d.getDeviceName(); } }; //vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<Device, String>getInstance( // LazyMap.<Device, String>decorate(new HashMap<Device, String>(), new ToStringLabeller<Device>()))); vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); vv.getRenderContext().setEdgeLabelTransformer(new Transformer<ComLink, String>() { @Override public String transform(ComLink link) { return (link.getID() + ", " + link.getLatency()); } }); //float dash[] = {0.1f}; //final Stroke edgeStroke = new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 1.0f); final Stroke edgeStroke = new BasicStroke(3.0f); final Transformer<ComLink, Stroke> edgeStrokeTransformer = new Transformer<ComLink, Stroke>() { @Override public Stroke transform(ComLink l) { return edgeStroke; } }; Transformer<ComLink, Paint> edgePaint = new Transformer<ComLink, Paint>() { public Paint transform(ComLink l) { if (l.isDown()) { return Color.RED; } else { return Color.BLACK; } } }; vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); vv.getRenderContext().setVertexIconTransformer(new CustomVertexIconTransformer()); vv.getRenderContext().setVertexShapeTransformer(new CustomVertexShapeTransformer()); vv.addPreRenderPaintable(new VisualizationViewer.Paintable() { @Override public void paint(Graphics grphcs) { for (Device d : Topology.getInstance().getGraph().getVertices()) { int size = d.getOperators().size(); MyLayeredIcon icon = d.getIcon(); //if(icon == null) continue; icon.removeAll(); if (size > 0) { // the vertex icon // Let's create the annotation image to be added to icon.. BufferedImage image = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); g.setColor(Color.ORANGE); g.fillOval(0, 0, 20, 20); g.setColor(Color.BLACK); g.drawString(size + "", 5, 13); g.dispose(); ImageIcon img = new ImageIcon(image); //Dimension id = new Dimension(icon.getIconWidth(), icon.getIconHeight()); //double x = vv.getModel().getGraphLayout().transform(d).getX(); //x -= (icon.getIconWidth() / 2); //double y = vv.getModel().getGraphLayout().transform(d).getY(); //y -= (icon.getIconHeight() / 2); //grphcs.drawImage(image, (int) Math.round(x), (int) Math.round(y), null); icon.add(img); } } } @Override public boolean useTransform() { return false; } }); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); Factory<Device> vertexFactory = DeviceFactory.getInstance(); Factory<ComLink> edgeFactory = ComLinkFactory.getInstance(); final EditingModalGraphMouse<Device, ComLink> graphMouse = new EditingModalGraphMouse<>( vv.getRenderContext(), vertexFactory, edgeFactory); // Trying out our new popup menu mouse plugin... PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin(); // Add some popup menus for the edges and vertices to our mouse plugin. JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame); JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu(frame); myPlugin.setEdgePopup(edgeMenu); myPlugin.setVertexPopup(vertexMenu); graphMouse.remove(graphMouse.getPopupEditingPlugin()); // Removes the existing popup editing plugin graphMouse.add(myPlugin); // Add our new plugin to the mouse // AnnotatingGraphMousePlugin<Device,ComLink> annotatingPlugin = // new AnnotatingGraphMousePlugin<>(vv.getRenderContext()); //graphMouse.add(annotatingPlugin); // the EditingGraphMouse will pass mouse event coordinates to the // vertexLocations function to set the locations of the vertices as // they are created // graphMouse.setVertexLocations(vertexLocations); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); //final ImageAtEdgePainter<String, String> imageAtEdgePainter = // new ImageAtEdgePainter<String, String>(vv, edge, image); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JButton help = new JButton("Help"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions); } }); JButton deploy = new JButton("Deploy"); deploy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // OPMapping algo here if (simu == null) { return; } GraphUtil<Device, ComLink> util = new GraphUtil<>(); for (EventProducer p : simu.getProducers()) { if (!p.isMapped()) { JOptionPane.showMessageDialog(frame, "Cannot map operators. Please deploy the producer: " + p.getName()); return; } } for (EventConsumer c : simu.getConsumers()) { if (!c.isMapped()) { JOptionPane.showMessageDialog(frame, "Cannot map operators. Please deploy the consumer: " + c.getName()); return; } System.out.println("-- Operator placement algorithm Greedy: " + c.getName() + " --"); Solution init = util.initialMapping(c.getGraph()); System.out.println(c.getGraph() + "\nInitial Mapping: " + init); OperatorMapping mapper = new OperatorMapping(); long T1, T2; System.out.println("--- OpMapping Algo Greedy --- "); T1 = System.currentTimeMillis(); Solution solution = mapper.opMapping(c.getGraph(), Topology.getInstance().getGraph(), init); T2 = System.currentTimeMillis(); System.out.println(solution); System.out.println("Solution founded in: " + (T2 - T1) + " ms"); } // Solution init = util.initialMapping(EPGraph.getInstance().getGraph()); // System.out.println("Initial Mapping: " + init); // OperatorMapping mapper = new OperatorMapping(); // long T1, T2; // System.out.println("--- OpMapping Algo Greedy --- "); // T1 = System.currentTimeMillis(); // Solution solution = mapper.opMapping(EPGraph.getInstance().getGraph(), // Topology.getInstance().getGraph(), init); // T2 = System.currentTimeMillis(); // System.out.println(solution); // System.out.println("Solution founded in: " + (T2 - T1) + " ms"); vv.repaint(); } }); JButton run = new JButton("Run"); run.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // run the simulation here System.out.println("Setting the simulation..."); for (EventConsumer c : simu.getConsumers()) { for (EPUnit op : c.getGraph().getVertices()) { if (op.isMapped()) { op.openIOchannels(); } else { JOptionPane.showMessageDialog(frame, "Cannot run, undeployed operators founded."); return; } } } //ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); System.out.println("Running the simulation..."); //scheduledExecutorService.execute(runner); for (Device device : Topology.getInstance().getGraph().getVertices()) { if (!device.isAlive()) { device.start(); } } for (ComLink link : Topology.getInstance().getGraph().getEdges()) { if (!link.isAlive()) { link.start(); } } for (EventConsumer c : simu.getConsumers()) { for (EPUnit op : c.getGraph().getVertices()) { if (op.isMapped() && op.getDevice() != null && !op.isAlive()) { op.start(); } } } } }); AnnotationControls<Device, ComLink> annotationControls = new AnnotationControls<Device, ComLink>( graphMouse.getAnnotatingPlugin()); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 30, 0); slider.setMinorTickSpacing(5); slider.setMajorTickSpacing(30); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setLabelTable(slider.createStandardLabels(15)); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); if (!slider.getValueIsAdjusting()) { speedSimulation(slider.getValue()); } } }); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); JComboBox modeBox = graphMouse.getModeComboBox(); controls.add(modeBox); controls.add(annotationControls.getAnnotationsToolBar()); controls.add(slider); controls.add(deploy); controls.add(run); controls.add(help); content.add(controls, BorderLayout.SOUTH); /* Custom JPanels can be added here */ // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //final GraphEditor demo = new GraphEditor(); }
From source file:jatoo.app.App.java
private JPopupMenu getWindowPopup(final Point location) { ///*from w w w . j a va2 s . c o m*/ // hide final JMenuItem hideItem = new JMenuItem(getText("popup.hide")); hideItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { hide(); } }); // // send to back final JMenuItem sendToBackItem = new JMenuItem(getText("popup.send_to_back")); sendToBackItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { sendToBack(); } }); // // always on top final JCheckBoxMenuItem alwaysOnTopItem = new JCheckBoxMenuItem(getText("popup.always_on_top"), isAlwaysOnTop()); alwaysOnTopItem.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent e) { setAlwaysOnTop(alwaysOnTopItem.isSelected()); } }); // // transparency final JSlider transparencySlider = new JSlider(JSlider.VERTICAL, 0, 100, getTransparency()); transparencySlider.setMajorTickSpacing(25); transparencySlider.setMinorTickSpacing(5); transparencySlider.setSnapToTicks(true); transparencySlider.setPaintTicks(true); transparencySlider.setPaintLabels(true); transparencySlider.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent e) { setTransparency(transparencySlider.getValue()); } }); final JMenu transparencyItem = new JMenu(getText("popup.transparency")); transparencyItem.add(transparencySlider); // // close final JMenuItem closeItem = new JMenuItem(getText("popup.close"), getIcon("close-016.png")); closeItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { System.exit(0); } }); // // the popup JPopupMenu popup = new JPopupMenu(getTitle()); popup.add(hideItem); popup.addSeparator(); popup.add(sendToBackItem); popup.add(alwaysOnTopItem); popup.add(transparencyItem); popup.addSeparator(); popup.add(closeItem); popup.setInvoker(popup); popup.setLocation(location); return popup; }
From source file:fr.free.hd.servers.gui.FaceView.java
private JPanel createKind() { JPanel panel = new JPanel(new GridLayout(3, 0)); final JSlider sliderX = new JSlider(); final JSlider sliderY = new JSlider(); final JComboBox box = new JComboBox(HandKeyEnum.values()); sliderX.setMinimum(-1000);/* w ww. j a va2s . com*/ sliderX.setMaximum(1000); sliderX.setMajorTickSpacing(100); sliderX.setPaintLabels(true); sliderX.setPaintTicks(true); sliderX.setPaintTrack(true); sliderY.setMinimum(-1000); sliderY.setMaximum(1000); sliderY.setMajorTickSpacing(100); sliderY.setPaintLabels(true); sliderY.setPaintTicks(true); sliderY.setPaintTrack(true); box.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { kind = (HandKeyEnum) e.getItem(); updateLabel(); } }); panel.add(box); sliderX.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (kind) { case HAND_KEY_2D: face.setAnchorX_2D(sliderX.getValue()); break; case HAND_KEY_2M: face.setAnchorX_2M(sliderX.getValue()); break; case HAND_KEY_1M: face.setAnchorX_1M(sliderX.getValue()); break; case HAND_KEY_2V: face.setAnchorX_2V(sliderX.getValue()); break; case HAND_KEY_3D: face.setAnchorX_3D(sliderX.getValue()); break; case HAND_KEY_3G: face.setAnchorX_3G(sliderX.getValue()); break; case HAND_KEY_4G: face.setAnchorX_4G(sliderX.getValue()); break; case HAND_KEY_5M: face.setAnchorX_5M(sliderX.getValue()); break; } updateLabel(); } }); sliderY.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (kind) { case HAND_KEY_2D: face.setAnchorY_2D(sliderY.getValue()); break; case HAND_KEY_2M: face.setAnchorY_2M(sliderY.getValue()); break; case HAND_KEY_1M: face.setAnchorY_1M(sliderY.getValue()); break; case HAND_KEY_2V: face.setAnchorY_2V(sliderY.getValue()); break; case HAND_KEY_3D: face.setAnchorY_3D(sliderY.getValue()); break; case HAND_KEY_3G: face.setAnchorY_3G(sliderY.getValue()); break; case HAND_KEY_4G: face.setAnchorY_4G(sliderY.getValue()); break; case HAND_KEY_5M: face.setAnchorY_5M(sliderY.getValue()); break; } updateLabel(); } }); panel.add(sliderX); panel.add(sliderY); return panel; }