List of usage examples for javax.swing BoxLayout Y_AXIS
int Y_AXIS
To view the source code for javax.swing BoxLayout Y_AXIS.
Click Source Link
From source file:edu.ucla.stat.SOCR.analyses.gui.PrincipalComponentAnalysis.java
protected void doGraph() { // graphComponent is available here // data: variables double xData, yData, residuals, predicted are available here after doAnalysis() is run. graphPanel.removeAll();//from w w w. j av a2 s. c o m /************************************/ JPanel innerPanel = new JPanel(); JScrollPane graphPane = new JScrollPane(innerPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); graphPanel.add(graphPane); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); ChartPanel chartPanel = null; // 1. scatter plot of data: yData vs. xData ////////System.out.println("MLR doGraph independentHeaderArray.length = " + independentHeaderArray.length); JFreeChart scatterChart = chartFactory.getLineChart( "Scatter Plot of " + dependentHeader + " vs. " + independentHeader, independentHeader, dependentHeader, xData, yData, "noline");//getChart(title, xlabel, ylabel, xdata,ydata) //JFreeChart scatterChart = chartFactory.getQQChart("Scatter Plot of " + dependentHeader + " vs " + independentHeader, independentHeader, dependentHeader, dependentHeader , xData, yData, "", 0, 0, ""); chartPanel = new ChartPanel(scatterChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); JFreeChart screePlot = chartFactory.getLineChart("Scree Plot of Eigenvalues", "Ordering of Eigenvalues (Descending Order)", "Eigenvalues", xData1, yData1);//getChart(title, xlabel, ylabel, xdata,ydata) chartPanel = new ChartPanel(screePlot, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); graphPanel.validate(); }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
private void initializeGui() { setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(100, 100, 640, 480);//from w w w .ja va2 s . com addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { actionExit(); } }); fileChooser = new JFileChooser(); //fileChooser.setFileFilter( hlfFileFilter ); hlfFileChooser = new JFileChooser(); hlfFileChooser.setFileFilter(hlfFileFilter); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('F'); menuBar.add(mnFile); menuLoadRom = new JMenuItem("Load ROM..."); menuLoadRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); menuLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); menuLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); menuLoadRom.setMnemonic('O'); mnFile.add(menuLoadRom); menuSaveRom = new JMenuItem("Save ROM"); menuSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); menuSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); menuSaveRom.setMnemonic('S'); menuSaveRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); mnFile.add(menuSaveRom); menuSaveRomAs = new JMenuItem("Save ROM As..."); menuSaveRomAs.setMnemonic('a'); menuSaveRomAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK)); menuSaveRomAs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRomAs(); } }); menuSaveRomAs .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_as.png"))); mnFile.add(menuSaveRomAs); mnFile.addSeparator(); menuLoadLevel = new JMenuItem("Load Level..."); menuLoadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); menuLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); menuLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); menuLoadLevel.setMnemonic('L'); mnFile.add(menuLoadLevel); menuReloadLevel = new JMenuItem("Reload Level"); menuReloadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); menuReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); menuReloadLevel.setMnemonic('R'); menuReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); mnFile.add(menuReloadLevel); menuSaveLevel = new JMenuItem("Save Level"); menuSaveLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0)); menuSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); menuSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); menuSaveLevel.setMnemonic('v'); mnFile.add(menuSaveLevel); //* mnFile.addSeparator(); menuImportLevel = new JMenuItem("Import Level..."); menuImportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)); menuImportLevel.setMnemonic('i'); menuImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); menuImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); mnFile.add(menuImportLevel); menuExportLevel = new JMenuItem("Export Level..."); menuExportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); menuExportLevel.setMnemonic('e'); menuExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); menuExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); mnFile.add(menuExportLevel); //*/ mnFile.addSeparator(); menuExit = new JMenuItem("Exit"); menuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); menuExit.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_exit.png"))); menuExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { actionExit(); } }); menuRecentFiles = new JMenu("Recent Files..."); mnFile.add(menuRecentFiles); mnFile.addSeparator(); menuExit.setMnemonic('X'); mnFile.add(menuExit); JMenu mnEdit = new JMenu("Edit"); mnEdit.setMnemonic('E'); menuBar.add(mnEdit); menuViewSpawn = new JCheckBoxMenuItem("View Spawn Point"); menuViewSpawn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0)); menuViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuClearLevel = new JMenuItem("Clear Level"); menuClearLevel.setMnemonic('c'); menuClearLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); menuClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); menuClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); mnEdit.add(menuClearLevel); mnEdit.addSeparator(); menuViewSpawn .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); menuViewSpawn.setMnemonic('S'); menuViewSpawn.setSelected(true); mnEdit.add(menuViewSpawn); menuViewItems = new JCheckBoxMenuItem("View Items"); menuViewItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0)); menuViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewItems.setSelected(true); menuViewItems .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); menuViewItems.setMnemonic('I'); mnEdit.add(menuViewItems); menuViewDoorItems = new JCheckBoxMenuItem("View Door Items"); menuViewDoorItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0)); menuViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewDoorItems.setSelected(true); menuViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); menuViewDoorItems.setMnemonic('D'); mnEdit.add(menuViewDoorItems); menuViewEnemies = new JCheckBoxMenuItem("View Enemies"); menuViewEnemies.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0)); menuViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewEnemies.setSelected(true); menuViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); menuViewEnemies.setMnemonic('E'); mnEdit.add(menuViewEnemies); menuViewTypes = new JCheckBoxMenuItem("View Combo Types"); menuViewTypes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0)); menuViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewTypes.setSelected(true); menuViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); menuViewTypes.setMnemonic('C'); mnEdit.add(menuViewTypes); mnEdit.addSeparator(); scaleMenuItem = new JCheckBoxMenuItem("Scale Level Display"); scaleMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0)); scaleMenuItem.setMnemonic('l'); scaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(false); } }); scaleMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); mnEdit.add(scaleMenuItem); gridMenuItem = new JCheckBoxMenuItem("Display grid"); gridMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0)); gridMenuItem.setMnemonic('G'); gridMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(false); } }); gridMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); mnEdit.add(gridMenuItem); //mnEdit.addSeparator(); mntmPreferences = new JMenuItem("Preferences..."); mntmPreferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionPreferences(); } }); mntmPreferences.setMnemonic('P'); mntmPreferences.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_preferences.png"))); //mnEdit.add(mntmPreferences); mnHelp = new JMenu("Help"); mnHelp.setMnemonic('H'); menuBar.add(mnHelp); mntmCheckUpdates = new JMenuItem("Check for Updates..."); mntmCheckUpdates.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK)); mntmCheckUpdates.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionCheckUpdates(); } }); mntmCheckUpdates.setMnemonic('c'); mntmCheckUpdates .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_update.png"))); mnHelp.add(mntmCheckUpdates); mntmAbout = new JMenuItem("Readme..."); mntmAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); mntmAbout.setMnemonic('r'); mntmAbout.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/about.png"))); mntmAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionAbout(); } }); mnHelp.addSeparator(); mnHelp.add(mntmAbout); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); contentPane.add(toolBar, BorderLayout.NORTH); barLoadRom = new JButton(""); barLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); barLoadRom.setToolTipText("Open"); barLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); toolBar.add(barLoadRom); barSaveRom = new JButton(""); barSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); barSaveRom.setToolTipText("Save"); barSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); toolBar.add(barSaveRom); toolBar.addSeparator(); barImportLevel = new JButton(""); barImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); barImportLevel.setToolTipText("Import Level"); barImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); toolBar.add(barImportLevel); barExportLevel = new JButton(""); barExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); barExportLevel.setToolTipText("Export Level"); barExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); toolBar.add(barExportLevel); toolBar.addSeparator(); barLoadLevel = new JButton(""); barLoadLevel.setToolTipText("Load Level"); barLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); barLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); toolBar.add(barLoadLevel); barReloadLevel = new JButton(""); barReloadLevel.setToolTipText("Reload Current Level"); barReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); barReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); toolBar.add(barReloadLevel); barSaveLevel = new JButton(""); barSaveLevel.setToolTipText("Save Level"); barSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); barSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); toolBar.add(barSaveLevel); toolBar.addSeparator(); barViewItems = new JToggleButton(""); barViewItems.setToolTipText("Toggle View Items"); barViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewSpawn = new JToggleButton(""); barViewSpawn.setToolTipText("Toggle View Spawn"); barViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barClearLevel = new JButton(""); barClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); barClearLevel.setToolTipText("Clear Level"); barClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); toolBar.add(barClearLevel); toolBar.addSeparator(); barViewSpawn.setSelected(true); barViewSpawn.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); toolBar.add(barViewSpawn); barViewItems.setSelected(true); barViewItems.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); toolBar.add(barViewItems); barViewDoorItems = new JToggleButton(""); barViewDoorItems.setToolTipText("Toggle View Door Items"); barViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewDoorItems.setSelected(true); barViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); toolBar.add(barViewDoorItems); barViewEnemies = new JToggleButton(""); barViewEnemies.setToolTipText("toggle View Enemies"); barViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewEnemies.setSelected(true); barViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); toolBar.add(barViewEnemies); barViewTypes = new JToggleButton(""); barViewTypes.setToolTipText("Toggle view Combo Help"); barViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewTypes.setSelected(true); barViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); toolBar.add(barViewTypes); barViewSpawn.setSelected(config.getBoolean("Hazelnutt.gui.viewSpawn", true)); barViewItems.setSelected(config.getBoolean("Hazelnutt.gui.viewItems", true)); barViewDoorItems.setSelected(config.getBoolean("Hazelnutt.gui.viewDoorItems", true)); barViewEnemies.setSelected(config.getBoolean("Hazelnutt.gui.viewEnemies", true)); barViewTypes.setSelected(config.getBoolean("Hazelnutt.gui.viewHelp", true)); panel = new JPanel(); contentPane.add(panel, BorderLayout.EAST); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); selectorPanel = new SelectorPanel(); selectorPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Combo & Entity Selector", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(selectorPanel); propertiesPanel = new PropertiesPanel(null); propertiesPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level Properties", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(propertiesPanel); toolBar.addSeparator(); scaleButton = new JToggleButton(""); scaleButton.setToolTipText("Toggle Scale Display"); scaleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(true); } }); scaleButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); toolBar.add(scaleButton); scaleButton.setSelected(config.getBoolean("Hazelnutt.gui.scaled", false)); gridButton = new JToggleButton(""); gridButton.setToolTipText("Display Grid"); gridButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(true); } }); gridButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); toolBar.add(gridButton); gridButton.setSelected(config.getBoolean("Hazelnutt.gui.grid", false)); Component horizontalGlue = Box.createHorizontalGlue(); toolBar.add(horizontalGlue); Component verticalGlue = Box.createVerticalGlue(); panel.add(verticalGlue); levelWrapper = new JPanel(); levelWrapper.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); contentPane.add(levelWrapper, BorderLayout.CENTER); levelWrapper.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); levelWrapper.add(scrollPane); levelDisplay = new LevelDisplay(); levelDisplay.addEditListener(new EditListener() { @Override public void leftPressed(int x, int y) { SelectionType st = selectorPanel.getSelectionType(); Object so = selectorPanel.getSelectedObject(); if (st == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) so).byteValue()); } else if (st == SelectionType.SPAWN) { selectedLevel.getRomLevel().setSpawn(new IntVector(x, y)); levelHasChanged = true; } else if (st == SelectionType.ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.DOOR_ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getDoorItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.ENEMY) { Enemy ent = new Enemy((EnemyType) so, x, y); EntityCollection<Enemy> ents = selectedLevel.getRomLevel().getEnemies(); for (Iterator<Enemy> it = ents.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } updateTitle(); levelDisplay.repaint(); levelHasChanged = true; } @Override public void centerPressed(int x, int y) { selectorPanel.forceComboSelection(selectedLevel.getRomLevel().getData()[x][y]); } @Override public void rightPressed(int x, int y) { deleteVisibleEntitiesAt(x, y); } @Override public void leftDragged(int x, int y) { if (selectorPanel.getSelectionType() == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) selectorPanel.getSelectedObject()).byteValue()); } } @Override public void centerDragged(int x, int y) { // Nothing to de here } @Override public void rightDragged(int x, int y) { deleteVisibleEntitiesAt(x, y); } // Utility methods /*private void selectComboAt ( int x, int y ) { }/**/ private void paintComboAt(int x, int y, byte value) { selectedLevel.getRomLevel().getData()[x][y] = value; levelHasChanged = true; updateTitle(); levelDisplay.repaint(); } private void deleteVisibleEntitiesAt(int x, int y) { Collection<Item> items = selectedLevel.getRomLevel().getItems(); Collection<Item> doorItems = selectedLevel.getRomLevel().getDoorItems(); Collection<Enemy> enemies = selectedLevel.getRomLevel().getEnemies(); if (barViewItems.isSelected()) { for (Iterator<Item> it = items.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewDoorItems.isSelected()) { for (Iterator<Item> it = doorItems.iterator(); it.hasNext();) { Item doorItem = it.next(); if (doorItem.getX() == x && doorItem.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewEnemies.isSelected()) { for (Iterator<Enemy> it = enemies.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); levelHasChanged = true; } } } updateTitle(); levelDisplay.repaint(); } }); scrollPane.setViewportView(levelDisplay); updateTitle(); actionToggle(true); actionScale(true); actionGrid(true); setIconImage(Toolkit.getDefaultToolkit() .getImage(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/witch_hazel_big.png"))); setRomFeaturesEnabled(false); setLevelFeaturesEnabled(false); if (config.getBoolean("Hazelnutt.gui.maximum", false)) { setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); } else { int x = config.getInt("Hazelnutt.gui.location.x", Integer.MIN_VALUE); int y = config.getInt("Hazelnutt.gui.location.y", Integer.MIN_VALUE); int w = config.getInt("Hazelnutt.gui.size.width", Integer.MIN_VALUE); int h = config.getInt("Hazelnutt.gui.size.height", Integer.MIN_VALUE); if (x == Integer.MIN_VALUE || x == Integer.MIN_VALUE || w == Integer.MIN_VALUE || h == Integer.MIN_VALUE) { setLocationRelativeTo(null); } else { setLocation(x, y); setSize(w, h); } } propertiesPanel.addApplyListener(new PropertiesPanel.ApplyListener() { @Override public void apply() { levelHasChanged = true; updateTitle(); updateDisplay(); } }); if (config.containsKey("Hazelnutt.gui.lastDirectory")) { File lastDir = new File(config.getString("Hazelnutt.gui.lastDirectory")); if (lastDir.exists() && lastDir.isDirectory()) { //logger.debug( "Resetting the last directory: '" + lastDir + "'" ); fileChooser.setCurrentDirectory(lastDir); } } // Configure the PgUp and PgDn shortcuts InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PgUp"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PgDn"); ActionMap am = contentPane.getActionMap(); am.put("PgUp", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelUp(); } }); am.put("PgDn", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelDown(); } }); // Get the recent files recentFiles = new LinkedList<String>(Arrays.asList(config.getStringArray("Hazelnutt.gui.recentFiles"))); updateRecentFiles(); }
From source file:lcmc.gui.resources.EditableInfo.java
/** * Creates panel with border and title for parameters with specified * background.//from w w w .jav a 2 s . c om */ protected final JPanel getParamPanel(final String title, final Color background) { final JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setBackground(background); final TitledBorder titleBorder = Tools.getBorder(title); panel.setBorder(titleBorder); return panel; }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/** * setup GUI layout for the show-all panel * *//*from w w w .j a v a2 s. com*/ protected void initMixPanel() { dataPanel2 = new JPanel(); dataPanel2.setLayout(new BoxLayout(dataPanel2, BoxLayout.Y_AXIS)); graphPanel2 = new JPanel(); // graphPanel2.setLayout(new BoxLayout(graphPanel2, BoxLayout.Y_AXIS)); mixPanel = new JPanel(new BorderLayout()); // resetChart(); setMixPanel(); }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/** * make the show_all panel/*from w w w . j a v a 2s .co m*/ */ protected void setMixPanel() { dataPanel2.removeAll(); graphPanel2.removeAll(); graphPanel2.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3)); graphPanel2.setLayout(new BoxLayout(graphPanel2, BoxLayout.Y_AXIS)); if (chartPanel != null) graphPanel2.add(chartPanel); if (legendPanelOn) { if (legendPanel != null) legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 5)); JScrollPane legendPane = new JScrollPane(legendPanel); legendPane.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 5)); graphPanel2.add(legendPane); } graphPanel2.validate(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Data")); JScrollPane dt = new JScrollPane(dataTable); dt.setRowHeaderView(headerTable); dt.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y * 3 / 8)); dataPanel2.add(dt); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 6)); dataPanel2.add(st); st.validate(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Mapping")); JScrollPane st2 = new JScrollPane(mapPanel); st2.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 2)); dataPanel2.add(st2); dataPanel2.validate(); mixPanel.removeAll(); mixPanel.add(graphPanel2, BorderLayout.WEST); mixPanel.add(new JScrollPane(dataPanel2), BorderLayout.CENTER); mixPanel.validate(); }
From source file:jp.massbank.spectrumsearch.SearchPage.java
/** * ?//from ww w . j a v a 2 s . c o m */ private void createWindow() { // ?? ToolTipManager ttm = ToolTipManager.sharedInstance(); ttm.setInitialDelay(50); ttm.setDismissDelay(8000); // Search? JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), new EmptyBorder(1, 1, 1, 1)); mainPanel.setBorder(border); // ********************************************************************* // User File Query // ********************************************************************* DefaultTableModel fileDm = new DefaultTableModel(); fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE); queryFileTable = new JTable(fileSorter) { @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; queryFileTable.addMouseListener(new TblMouseListener()); fileSorter.setTableHeader(queryFileTable.getTableHeader()); queryFileTable.setRowSelectionAllowed(true); queryFileTable.setColumnSelectionAllowed(false); queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID }; ((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col); (queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44); (queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44); (queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70); ListSelectionModel lm = queryFileTable.getSelectionModel(); lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lm.addListSelectionListener(new LmFileListener()); queryFilePane = new JScrollPane(queryFileTable); queryFilePane.addMouseListener(new PaneMouseListener()); queryFilePane.setPreferredSize(new Dimension(300, 300)); // ********************************************************************* // Result // ********************************************************************* DefaultTableModel resultDm = new DefaultTableModel(); resultSorter = new TableSorter(resultDm, TABLE_RESULT); resultTable = new JTable(resultSorter) { @Override public String getToolTipText(MouseEvent me) { // super.getToolTipText(me); // ????? Point pt = me.getPoint(); int row = rowAtPoint(pt); if (row < 0) { return null; } else { int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME); return " " + getValueAt(row, nameCol) + " "; } } @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; resultTable.addMouseListener(new TblMouseListener()); resultSorter.setTableHeader(resultTable.getTableHeader()); JPanel dbPanel = new JPanel(); dbPanel.setLayout(new BorderLayout()); resultPane = new JScrollPane(resultTable); resultPane.addMouseListener(new PaneMouseListener()); resultTable.setRowSelectionAllowed(true); resultTable.setColumnSelectionAllowed(false); resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO }; resultDm.setColumnIdentifiers(col2); (resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180); (resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20); (resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20); (resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50); ListSelectionModel lm2 = resultTable.getSelectionModel(); lm2.addListSelectionListener(new LmResultListener()); resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200)); dbPanel.add(resultPane, BorderLayout.CENTER); // ********************************************************************* // DB Query // ********************************************************************* DefaultTableModel dbDm = new DefaultTableModel(); querySorter = new TableSorter(dbDm, TABLE_QUERY_DB); queryDbTable = new JTable(querySorter) { @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; queryDbTable.addMouseListener(new TblMouseListener()); querySorter.setTableHeader(queryDbTable.getTableHeader()); queryDbPane = new JScrollPane(queryDbTable); queryDbPane.addMouseListener(new PaneMouseListener()); int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h)); queryDbTable.setRowSelectionAllowed(true); queryDbTable.setColumnSelectionAllowed(false); queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO }; DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel(); model.setColumnIdentifiers(col3); // queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70); queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70); queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70); queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50); ListSelectionModel lm3 = queryDbTable.getSelectionModel(); lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lm3.addListSelectionListener(new LmQueryDbListener()); // ? JPanel btnPanel = new JPanel(); btnName.addActionListener(new BtnSearchNameListener()); btnAll.addActionListener(new BtnAllListener()); btnPanel.add(btnName); btnPanel.add(btnAll); parentPanel2 = new JPanel(); parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS)); parentPanel2.add(btnPanel); parentPanel2.add(queryDbPane); // ? JPanel dispModePanel = new JPanel(); isDispSelected = dispSelected.isSelected(); isDispRelated = dispRelated.isSelected(); if (isDispSelected) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } else if (isDispRelated) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } Object[] retRadio = new Object[] { dispSelected, dispRelated }; for (int i = 0; i < retRadio.length; i++) { ((JRadioButton) retRadio[i]).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) { isDispSelected = dispSelected.isSelected(); isDispRelated = dispRelated.isSelected(); // ?? resultTable.clearSelection(); resultPlot.clear(); compPlot.setPeaks(null, 1); resultPlot.setPeaks(null, 0); setAllPlotAreaRange(); pkgView.initResultRecInfo(); if (isDispSelected) { resultTable.getSelectionModel() .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } else if (isDispRelated) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } } } }); } ButtonGroup disGroup = new ButtonGroup(); disGroup.add(dispSelected); disGroup.add(dispRelated); dispModePanel.add(lbl2); dispModePanel.add(dispSelected); dispModePanel.add(dispRelated); JPanel paramPanel = new JPanel(); paramPanel.add(etcPropertyButton); etcPropertyButton.setMargin(new Insets(0, 10, 0, 10)); etcPropertyButton.addActionListener(new ActionListener() { private ParameterSetWindow ps = null; public void actionPerformed(ActionEvent e) { // ?????????? if (!isSubWindow) { ps = new ParameterSetWindow(getParentFrame()); } else { ps.requestFocus(); } } }); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); optionPanel.add(dispModePanel); optionPanel.add(paramPanel); // PackageView????? pkgView = new PackageViewPanel(); pkgView.initAllRecInfo(); queryTabPane.addTab("DB", parentPanel2); queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB."); queryTabPane.addTab("File", queryFilePane); queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file."); queryTabPane.setSelectedIndex(TAB_ORDER_DB); queryTabPane.setFocusable(false); queryTabPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // ? queryPlot.clear(); compPlot.clear(); resultPlot.clear(); queryPlot.setPeaks(null, 0); compPlot.setPeaks(null, 1); resultPlot.setPeaks(null, 0); // PackageView? pkgView.initAllRecInfo(); // DB Hit? if (resultTabPane.getTabCount() > 0) { resultTabPane.setSelectedIndex(0); } DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel(); dataModel.setRowCount(0); hitLabel.setText(" "); // DB?User File?????? queryTabPane.update(queryTabPane.getGraphics()); if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) { parentPanel2.update(parentPanel2.getGraphics()); updateSelectQueryTable(queryDbTable); } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) { queryFilePane.update(queryFilePane.getGraphics()); updateSelectQueryTable(queryFileTable); } } }); // JPanel queryPanel = new JPanel(); queryPanel.setLayout(new BorderLayout()); queryPanel.add(queryTabPane, BorderLayout.CENTER); queryPanel.add(optionPanel, BorderLayout.SOUTH); queryPanel.setMinimumSize(new Dimension(0, 170)); JPanel jtp2Panel = new JPanel(); jtp2Panel.setLayout(new BorderLayout()); jtp2Panel.add(dbPanel, BorderLayout.CENTER); jtp2Panel.add(hitLabel, BorderLayout.SOUTH); jtp2Panel.setMinimumSize(new Dimension(0, 70)); Color colorGreen = new Color(0, 128, 0); hitLabel.setForeground(colorGreen); resultTabPane.addTab("Result", jtp2Panel); resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit."); resultTabPane.setFocusable(false); queryPlot.setMinimumSize(new Dimension(0, 100)); compPlot.setMinimumSize(new Dimension(0, 120)); resultPlot.setMinimumSize(new Dimension(0, 100)); int height = initAppletHight / 3; JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot); JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db); jsp_cmp2db.setDividerLocation(height); jsp_qry2cmp.setDividerLocation(height - 25); jsp_qry2cmp.setMinimumSize(new Dimension(190, 0)); viewTabPane.addTab("Compare View", jsp_qry2cmp); viewTabPane.addTab("Package View", pkgView); viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum."); viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum."); viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE); viewTabPane.setFocusable(false); JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane); jsp.setDividerLocation(310); jsp.setMinimumSize(new Dimension(180, 0)); jsp.setOneTouchExpandable(true); JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane); int divideSize = (int) (initAppletWidth * 0.4); divideSize = (divideSize >= 180) ? divideSize : 180; jsp2.setDividerLocation(divideSize); jsp2.setOneTouchExpandable(true); mainPanel.add(jsp2, BorderLayout.CENTER); add(mainPanel); queryPlot.setSearchPage(this); compPlot.setSearchPage(this); resultPlot.setSearchPage(this); setJMenuBar(MenuBarGenerator.generateMenuBar(this)); }
From source file:davmail.ui.SettingsFrame.java
protected JPanel getLoggingSettingsPanel() { JPanel loggingLevelPanel = new JPanel(); JPanel leftLoggingPanel = new JPanel(new GridLayout(2, 2)); JPanel rightLoggingPanel = new JPanel(new GridLayout(2, 2)); loggingLevelPanel.add(leftLoggingPanel); loggingLevelPanel.add(rightLoggingPanel); rootLoggingLevelField = new JComboBox(LOG_LEVELS); davmailLoggingLevelField = new JComboBox(LOG_LEVELS); httpclientLoggingLevelField = new JComboBox(LOG_LEVELS); wireLoggingLevelField = new JComboBox(LOG_LEVELS); logFilePathField = new JTextField(Settings.getProperty("davmail.logFilePath"), 15); logFileSizeField = new JTextField(Settings.getProperty("davmail.logFileSize"), 15); rootLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("rootLogger")); davmailLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("davmail")); httpclientLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("org.apache.commons.httpclient")); wireLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("httpclient.wire")); addSettingComponent(leftLoggingPanel, BundleMessage.format("UI_LOG_DEFAULT"), rootLoggingLevelField); addSettingComponent(leftLoggingPanel, BundleMessage.format("UI_LOG_DAVMAIL"), davmailLoggingLevelField); addSettingComponent(rightLoggingPanel, BundleMessage.format("UI_LOG_HTTPCLIENT"), httpclientLoggingLevelField); addSettingComponent(rightLoggingPanel, BundleMessage.format("UI_LOG_WIRE"), wireLoggingLevelField); JPanel logFilePathPanel = new JPanel(new GridLayout(2, 2)); addSettingComponent(logFilePathPanel, BundleMessage.format("UI_LOG_FILE_PATH"), logFilePathField); addSettingComponent(logFilePathPanel, BundleMessage.format("UI_LOG_FILE_SIZE"), logFileSizeField); JButton defaultButton = new JButton(BundleMessage.format("UI_BUTTON_DEFAULT")); defaultButton.setToolTipText(BundleMessage.format("UI_BUTTON_DEFAULT_HELP")); defaultButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rootLoggingLevelField.setSelectedItem(Level.WARN); davmailLoggingLevelField.setSelectedItem(Level.DEBUG); httpclientLoggingLevelField.setSelectedItem(Level.WARN); wireLoggingLevelField.setSelectedItem(Level.WARN); }//from w w w.ja v a 2 s. c om }); JPanel loggingPanel = new JPanel(); loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS)); loggingPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LOGGING_LEVELS"))); loggingPanel.add(logFilePathPanel); loggingPanel.add(loggingLevelPanel); loggingPanel.add(defaultButton); updateMaximumSize(loggingPanel); return loggingPanel; }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel plotPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); String[] labels0 = { "S2C0 ", "S2C1 ", "PCIe Reads " }; String[] labels1 = { "C2S0 ", "C2S1 ", "PCIe Writes " }; dma0chart = new DMABarChart("Transmit (S2C) Performance", panel1.getBackground(), labels0); dma1chart = new DMABarChart("Receive (C2S) Performance", panel1.getBackground(), labels1); panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); panel1.setSize(new Dimension(panel1.getWidth() - 100, panel1.getHeight() - 100)); panel1.add(dma0chart.getChart("")); panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS)); panel2.setSize(new Dimension(panel2.getWidth() - 100, panel2.getHeight() - 100)); panel2.add(dma1chart.getChart("")); panel.add(panel1);/*from w ww.j av a 2 s .c o m*/ panel.add(panel2); return panel; }
From source file:edu.ucla.stat.SOCR.analyses.gui.LogisticRegression.java
protected void doGraph() { // graphComponent is available here // data: variables double xData, yData, residuals, predicted are available here after doAnalysis() is run. graphPanel.removeAll();//w ww . j a v a 2s.c o m /************************************/ JPanel innerPanel = new JPanel(); JScrollPane graphPane = new JScrollPane(innerPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); graphPanel.add(graphPane); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); //JFreeChart scatterChart = chartFactory.getQQChart("Scatter Plot of " + dependentHeader + " vs " + independentHeader, independentHeader, dependentHeader, dependentHeader + " Value " , xData, yData, "Regression Line", intercept, slope, ""); //ChartPanel chartPanel = new ChartPanel(scatterChart, false); //chartPanel.setPreferredSize(new Dimension(plotWidth,plotHeight)); //innerPanel.add(chartPanel); /************************************/ ChartPanel chartPanel = null; // 1. scatter plot of data: yData vs. xData ////////System.out.println("MLR doGraph independentHeaderArray.length = " + independentHeaderArray.length); for (int i = 0; i < xDataArray.length; i++) { xData = xDataArray[i]; independentHeader = independentHeaderArray[i]; JFreeChart scatterChart = chartFactory.getLineChart( "Scatter Plot of " + dependentHeader + " vs. " + independentHeader, independentHeader, dependentHeader, xData, yData, "noline");//getChart(title, xlabel, ylabel, xdata,ydata) //JFreeChart scatterChart = chartFactory.getQQChart("Scatter Plot of " + dependentHeader + " vs " + independentHeader, independentHeader, dependentHeader, dependentHeader , xData, yData, "", 0, 0, ""); chartPanel = new ChartPanel(scatterChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); } // this is only a test for having more than one charts in a boxlayout // 2. residual on fit plot: residuals vs. predicted JFreeChart rfChart = chartFactory.getLineChart("Residual on Fit Plot", "Predicted", "Residuals", predicted, residuals, "noline"); //JFreeChart rfChart = chartFactory.getQQChart("Residual on Fit Plot", "Predicted", "Residuals", " Predicted Value " , predicted, residuals, "At Residual = 0", 0, 0, ""); chartPanel = new ChartPanel(rfChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); // 3. residual on fit plot: residuals vs. xData /*JFreeChart rxChart = chartFactory.getLineChart("Residual on covariate Plot", "xData", "Residuals", xData, residuals); chartPanel = new ChartPanel(rxChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth,plotHeight)); graphPanel.add(chartPanel); */ for (int i = 0; i < xDataArray.length; i++) { xData = xDataArray[i]; independentHeader = independentHeaderArray[i]; JFreeChart scatterChart = chartFactory.getLineChart( "Residual on covariate Plot: Residuals vs. " + independentHeader, independentHeader, "Residuals", xData, yData, "noline");//getChart(title, xlabel, ylabel, xdata,ydata) //JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals, "noline"); //JFreeChart scatterChart = chartFactory.getQQChart("Residual on Covariate Plot: Residuals vs. " + independentHeader, independentHeader, "Residuals", "Residuals" , xData, residuals, "At Residual = 0", 0, 0, "noline"); chartPanel = new ChartPanel(scatterChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); } // 4. Normal QQ plot: need residuals and standardized normal scores //JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals); //JFreeChart qqChart = chartFactory.getQQChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", "", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals, "", 0, 0, ""); JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals, "noline"); chartPanel = new ChartPanel(qqChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); graphPanel.validate(); }
From source file:edu.ucla.stat.SOCR.analyses.gui.AnovaTwoWay.java
protected void doGraph() { graphPanel.removeAll();//from www . j a va 2s .c o m // 1. Box plot of data: yData vs. xData (where xData is categorical) JPanel innerPanel = new JPanel(); JScrollPane graphPane = new JScrollPane(innerPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); graphPanel.add(graphPane); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); String[][] xNameData = new String[seriesCount][categoryCount]; // xNameData: category names. //////System.out.println("xNameData = "+xNameData.length); for (int i = 0; i < seriesCount; i++) { for (int j = 0; j < categoryCount; j++) { xNameData[i][j] = categoryName[j]; //////System.out.println("xNameData = " + xNameData[i][j]); } } /* the parameters to be passed are: 1.boxPlotTitle, xAxisLabel, YAxisLabel. 2. serieCount, categoryCount 3. seriesname (e.g. sex, race, etc) 4. category's name (e.g. height, weight, etc)--xData 5. yValue(double), */ ChartPanel chartPanel = null; double xDataDouble[] = null; TreeSet<String> treeSet = new TreeSet<String>(); String groupLegend = ""; boolean groupHasChar = false; // 1. scatter plot of data: yData vs. xData try { for (int i = xDataArray.length - 1; i >= 0; i--) { xData = xDataArray[i]; xDataDouble = new double[xData.length]; try { for (int j = 0; j < xData.length; j++) { xDataDouble[j] = (new Double(xData[j])).doubleValue(); } } catch (Exception e) { for (int j = 0; j < xData.length; j++) { treeSet.add((String) xData[j]); } groupHasChar = true; } Iterator iterator = treeSet.iterator(); int groupIndex = 1; String groupName = null; while (iterator.hasNext()) { groupName = (String) iterator.next(); //xDataDouble[groupIndex-1] = groupIndex; groupLegend += ("\t" + groupName + "=" + groupIndex + " "); for (int j = 0; j < xData.length; j++) { if (xData[j].equalsIgnoreCase(groupName)) { // xData[i] is a String. xDataDouble[j] = (double) groupIndex; } } groupIndex++; } independentHeader = independentHeaderArray[i]; //JFreeChart scatterChart = chartFactory.getLineChart("Scatter Plot of " + dependentHeader + " vs. " + independentHeader, independentHeader, dependentHeader, xDataDouble, yData);//getChart(title, xlabel, ylabel, xdata,ydata) JFreeChart scatterChart = chartFactory.getQQChart( "Scatter Plot of " + dependentHeader + " vs. " + independentHeader, independentHeader, dependentHeader, "Residuals ", xDataDouble, yData, " " + groupLegend, 0, 0, ""); ////System.out.println("doGraph dependentHeader = " + dependentHeader); ////System.out.println("doGraph independentHeader = " + independentHeader); chartPanel = new ChartPanel(scatterChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); if (groupHasChar) { groupLegend = "Group Names for " + independentHeaderArray[i] + ": " + groupLegend; /*JLabel legendLabel1 = new JLabel(groupLegend); legendLabel1.setBackground(Color.WHITE); JPanel labelPanel1 = new JPanel(); labelPanel1.add(legendLabel1, BorderLayout.NORTH); innerPanel.add(labelPanel1); */ } groupLegend = ""; treeSet = new TreeSet<String>(); } } catch (Exception e) { ////System.out.println("doGraph Scatter Exception = " + e); } groupHasChar = false; // 2. residual on fit plot: residuals vs. predicted //JFreeChart rfChart = chartFactory.getLineChart("Residual on Fit Plot", "Predicted", "Residuals", predicted, residuals, "Other Stuff"); JFreeChart rfChart = chartFactory.getQQChart("Residual on Fit Plot", "Predicted " + dependentHeader, "Residuals", "Residuals ", predicted, residuals, "At Residual = 0", 0, 0, ""); for (int i = 0; i < predicted.length; i++) { //System.out.println("predicted["+i+"] = " + predicted[i] + ". residuals["+i+"] = " + residuals[i]); } chartPanel = new ChartPanel(rfChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); // 3. residual on fit plot: residuals vs. xData xDataDouble = new double[xData.length]; groupLegend = ""; boolean useStringLegent = false; treeSet = new TreeSet<String>(); try { for (int i = xDataArray.length - 1; i >= 0; i--) { xData = xDataArray[i]; xDataDouble = new double[xData.length]; try { for (int j = 0; j < xData.length; j++) { xDataDouble[j] = (new Double(xData[j])).doubleValue(); } } catch (Exception e) { for (int j = 0; j < xData.length; j++) { treeSet.add((String) xData[j]); } groupHasChar = true; } Iterator<String> iterator = treeSet.iterator(); int groupIndex = 1; String groupName = null; while (iterator.hasNext()) { groupName = (String) iterator.next(); //xDataDouble[groupIndex-1] = groupIndex; groupLegend += ("\t" + groupName + "=" + groupIndex + " "); for (int j = 0; j < xData.length; j++) { if (xData[j].equalsIgnoreCase(groupName)) { // xData[i] is a String. xDataDouble[j] = (double) groupIndex; } } groupIndex++; } independentHeader = independentHeaderArray[i]; //JFreeChart scatterChart = chartFactory.getLineChart("Residual on Covariate Plot, Residual vs. " + independentHeaderArray[i], independentHeaderArray[i], dependentHeader, xDataDouble, residuals, "Other Stuff 2");//getChart(title, xlabel, ylabel, xdata,ydata) JFreeChart scatterChart = chartFactory.getQQChart( "Residual on Covariate Plot: Variable = " + independentHeaderArray[i], independentHeaderArray[i], "Residuals", "Residual ", xDataDouble, residuals, " " + groupLegend, 0, 0, "noline"); chartPanel = new ChartPanel(scatterChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); if (groupHasChar) { groupLegend = "Group Names for " + independentHeaderArray[i] + ": " + groupLegend; /* JLabel legendLabel2 = new JLabel(groupLegend); legendLabel2.setBackground(Color.WHITE); JPanel labelPanel2 = new JPanel(); labelPanel2.add(legendLabel2, BorderLayout.NORTH); innerPanel.add(labelPanel2); */ } groupLegend = ""; treeSet = new TreeSet<String>(); } } catch (Exception e) { ////System.out.println("doGraph Residuals Exception = " + e); } // 4. Normal QQ plot: need residuals and standardized normal scores //JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals); JFreeChart qqChart = chartFactory.getQQChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", "Standardized Residual Value ", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals, "At Standardized Residual = 0", 0, 1, "noshape"); //JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals); //JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals, "noline"); chartPanel = new ChartPanel(qqChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); graphPanel.validate(); }