List of usage examples for javax.swing JLabel setUI
@BeanProperty(hidden = true, visualUpdate = true, description = "The UI object that implements the Component's LookAndFeel.") public void setUI(LabelUI ui)
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("java2s.com"); label.setUI(new VerticalLabelUI(true)); JOptionPane.showMessageDialog(null, label); }
From source file:com.qspin.qtaste.ui.MainPanel.java
public void genUI() { try {//from ww w . j a va 2 s.c om getContentPane().setLayout(new BorderLayout()); // prepare the top panel that contains the following panes: // - logo // - ConfigInfopanel // - Current Date/time JPanel topanel = new JPanel(new BorderLayout()); JPanel center = new JPanel(new GridBagLayout()); ImageIcon topLeftLogo = ResourceManager.getInstance().getImageIcon("main/qspin"); JLabel iconlabel = new JLabel(topLeftLogo); mHeaderPanel = new ConfigInfoPanel(this); mTestCasePanel = new TestCasePane(this); mTestCampaignPanel = new TestCampaignMainPanel(this); mHeaderPanel.init(); GridBagLineAdder centeradder = new GridBagLineAdder(center); JLabel sep = new JLabel(" "); sep.setFont(ResourceManager.getInstance().getSmallFont()); sep.setUI(new FillLabelUI(ResourceManager.getInstance().getLightColor())); centeradder.setWeight(1.0f, 0.0f); centeradder.add(mHeaderPanel); // prepare the right panels containg the main information: // the right pane is selected through the tabbed pane: // - Test cases: management of test cases and test suites // - Test campaign: management of test campaigns // - Interactive: ability to invoke QTaste verbs one by one mRightPanels = new JPanel(new CardLayout()); mRightPanels.add(mTestCasePanel, "Test Cases"); mRightPanels.add(mTestCampaignPanel, "Test Campaign"); final TestCaseInteractivePanel testInterractivePanel = new TestCaseInteractivePanel(); mRightPanels.add(testInterractivePanel, "Interactive"); mTreeTabsPanel = new JTabbedPane(JTabbedPane.BOTTOM); mTreeTabsPanel.setPreferredSize(new Dimension(TREE_TABS_WIDTH, HEIGHT)); TestCaseTree tct = new TestCaseTree(mTestCasePanel); JScrollPane sp2 = new JScrollPane(tct); mTreeTabsPanel.addTab("Test Cases", sp2); // add tree view for test campaign definition com.qspin.qtaste.ui.testcampaign.TestCaseTree mtct = new com.qspin.qtaste.ui.testcampaign.TestCaseTree( mTestCampaignPanel.getTreeTable()); JScrollPane sp3 = new JScrollPane(mtct); mTreeTabsPanel.addTab("Test Campaign", sp3); genMenu(tct); // add another tab contain used for Interactive mode TestAPIDocsTree jInteractive = new TestAPIDocsTree(testInterractivePanel); JScrollPane spInter = new JScrollPane(jInteractive); mTreeTabsPanel.addTab("Interactive", spInter); // init will do the link between the tree view and the pane testInterractivePanel.init(); // Define the listener to display the pane depending on the selected tab mTreeTabsPanel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { String componentName = mTreeTabsPanel.getTitleAt(mTreeTabsPanel.getSelectedIndex()); CardLayout rcl = (CardLayout) mRightPanels.getLayout(); rcl.show(mRightPanels, componentName); } }); mTestCampaignPanel.addTestCampaignActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getID() == TestCampaignMainPanel.RUN_ID) { if (e.getActionCommand().equals(TestCampaignMainPanel.STARTED_CMD)) { // open the tab test cases SwingUtilities.invokeLater(new Runnable() { public void run() { mTreeTabsPanel.setSelectedIndex(0); mTestCasePanel.setSelectedTab(TestCasePane.RESULTS_INDEX); } }); // update the buttons mTestCasePanel.setExecutingTestCampaign(true, ((TestCampaignMainPanel) e.getSource()).getExecutionThread()); mTestCasePanel.updateButtons(true); } else if (e.getActionCommand().equals(TestCampaignMainPanel.STOPPED_CMD)) { mTestCasePanel.setExecutingTestCampaign(false, null); mTestCasePanel.updateButtons(); } } } }); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTreeTabsPanel, mRightPanels); splitPane.setDividerSize(4); GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); int mainHorizontalSplitDividerLocation = guiConfiguration .getInt(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, 285); splitPane.setDividerLocation(mainHorizontalSplitDividerLocation); splitPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("dividerLocation")) { GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); if (evt.getSource() instanceof JSplitPane) { JSplitPane splitPane = (JSplitPane) evt.getSource(); guiConfiguration.setProperty(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, splitPane.getDividerLocation()); try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } } } }); topanel.add(iconlabel, BorderLayout.WEST); topanel.add(center); getContentPane().add(topanel, BorderLayout.NORTH); getContentPane().add(splitPane); this.pack(); this.setExtendedState(Frame.MAXIMIZED_BOTH); if (mTestSuiteDir != null) { DirectoryTestSuite testSuite = DirectoryTestSuite.createDirectoryTestSuite(mTestSuiteDir); if (testSuite != null) { testSuite.setExecutionLoops(mNumberLoops, mLoopsInHour); setTestSuite(testSuite.getName()); mTestCasePanel.runTestSuite(testSuite, false); } } setVisible(true); //treeTabs.setMinimumSize(new Dimension(100, this.HEIGHT)); } catch (Exception e) { logger.fatal(e); e.printStackTrace(); TestEngine.shutdown(); System.exit(1); } }
From source file:com.google.code.facebook.graph.sna.applet.LensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * // w ww. j a v a 2 s. c o m */ public LensDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); 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()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:edu.uci.ics.jung.samples.LensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * /*from w ww. j av a 2 s.c o m*/ */ @SuppressWarnings({ "rawtypes", "unchecked" }) public LensDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); 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()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:graph.jung2.MyLensDemo.java
public void init() { // create a simple graph for the demo TemporalNetworkOfWikipediaNodes net = null; try {/*from w ww .ja v a2 s . c om*/ // net = new TemporalNetworkOfWikipediaNodes(null, null); net = new TemporalNetworkOfWikipediaNodes(r, level); graph = net.createSampleNetwork(); //getCC_EDIT_Graph(); } catch (Exception ex) { Logger.getLogger(MyLensDemo.class.getName()).log(Level.SEVERE, null, ex); } // if ( net == null ) { // graph = TemporalNetworkOfWikipediaNodes.createSampleNetwork(); // } // else { // graph = net.getGraph(); // } graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); 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()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:com.diversityarrays.kdxplore.KDXploreFrame.java
private void initialiseKdxApps() throws IOException { String[] classNames = KdxploreConfig.getInstance().getMainPluginClassNames(); if (classNames != null && classNames.length > 0) { List<String> classNamesToLoad = new ArrayList<>(); Collections.addAll(classNamesToLoad, classNames); if (!classNamesToLoad.contains(OFFLINE_DATA_APP_SERVICE_CLASS_NAME)) { classNamesToLoad.add(0, OFFLINE_DATA_APP_SERVICE_CLASS_NAME); classNames = classNamesToLoad.toArray(new String[classNamesToLoad.size()]); }//www. ja v a 2 s . com } Map<KdxApp, Component> componentByApp = collectKdxApps(classNames); appByComponent.clear(); for (KdxApp app : componentByApp.keySet()) { Component comp = componentByApp.get(app); if (comp != null) { appByComponent.put(comp, app); } } allKdxApps.clear(); allKdxApps.addAll(componentByApp.keySet()); // Initialise the apps in initialisation order. allKdxApps.sort(Comparator.comparing(KdxApp::getInitialisationOrder)); // And while we're initialising them we collect // those that can perform a databaseBackup (i.e. have a BackupProvider). backupProviders.clear(); List<KdxApp> wantedAppsWithUi = new ArrayList<>(); for (KdxApp app : allKdxApps) { BackupProvider bp = app.getBackupProvider(); if (bp != null) { backupProviders.add(bp); } /** * See {@link com.diversityarrays.kdxplore.prefs.KdxplorePreferences#SHOW_ALL_APPS} */ if (appIsWanted(app)) { try { app.initialiseAppBeforeUpdateCheck(appInitContext); } catch (Exception e) { String msg = Msg.MSG_KDXAPP_INIT_PROBLEM(app.getAppName()); Shared.Log.w(TAG, msg, e); messagesPanel.println(msg); messagesPanel.println(e.getMessage()); } } if (appIsWanted(app) && null != componentByApp.get(app)) { wantedAppsWithUi.add(app); } } // - - - - - - - - - - - - - - - - - - - - - // Display the apps in display order. wantedAppsWithUi.sort(Comparator.comparing(KdxApp::getDisplayOrder)); backupProviders.sort(Comparator.comparing(BackupProvider::getDisplayOrder)); switch (wantedAppsWithUi.size()) { case 0: JLabel label = new JLabel(Msg.MSG_NO_KDXPLORE_APPS_AVAILABLE()); label.setHorizontalAlignment(JLabel.CENTER); cardPanel.add(label, CARD_KDXAPPS); break; case 1: KdxApp kdxApp = wantedAppsWithUi.get(0); Component uiComponent = componentByApp.get(kdxApp); Component appComponent = makeComponentForTab(kdxApp, uiComponent); cardPanel.add(appComponent, CARD_KDXAPPS); getRootPane().setDefaultButton(kdxApp.getDefaultButton()); String msg = Msg.MSG_SHOWING_KDXAPP(kdxApp.getAppName()); messagesPanel.println(msg); System.err.println(msg + " uiClass=" //$NON-NLS-1$ + uiComponent.getClass().getName()); break; default: kdxAppTabs = new JTabbedPane(JTabbedPane.LEFT); cardPanel.add(kdxAppTabs, CARD_KDXAPPS); Bag<String> tabsSeen = new HashBag<>(); for (KdxApp app : wantedAppsWithUi) { Component ui = componentByApp.get(app); String tabName = app.getAppName(); DevelopmentState devState = app.getDevelopmentState(); switch (devState) { case ALPHA: tabName = tabName + " (\u03b1)"; // TODO move to UnicodeChars break; case BETA: tabName = tabName + " (\u03b2)"; // TODO move to UnicodeChars break; case PRODUCTION: break; default: tabName = tabName + " " + devState.name(); break; } tabsSeen.add(tabName); int count = tabsSeen.getCount(tabName); if (count > 1) { tabName = tabName + "_" + count; //$NON-NLS-1$ } Component tabComponent = makeComponentForTab(app, ui); kdxAppTabs.addTab(tabName, tabComponent); if (macapp == null) { int index = kdxAppTabs.indexOfTab(tabName); if (index >= 0) { JLabel tabLabel = new JLabel(tabName); tabLabel.setBorder(new EmptyBorder(2, 2, 2, 2)); tabLabel.setUI(new VerticalLabelUI(VerticalLabelUI.UPWARDS)); kdxAppTabs.setTabComponentAt(index, tabLabel); } } messagesPanel.println(Msg.MSG_SHOWING_KDXAPP(tabName)); } kdxAppTabs.addChangeListener(kdxAppTabsChangeListener); kdxAppTabs.setSelectedIndex(0); break; } }