List of usage examples for java.awt BorderLayout EAST
String EAST
To view the source code for java.awt BorderLayout EAST.
Click Source Link
From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java
/** * @param fi/* ww w .j a v a 2s . c om*/ * @return */ protected FormPanelInfo createPanel(final FormInfo formInfo) { CellConstraints cc = new CellConstraints(); JPanel panel = new JPanel(null); int maxWidth = 0; int maxHeight = 0; int maxCellWidth = 0; int maxCellHeight = 0; for (FormFieldInfo fi : formInfo.getFields()) { System.out.println(fi.getCaption()); boolean addLbl = true; JComponent comp = null; switch (fi.getControlTypeNum()) { case 4: comp = createComboBox(); // 'Picklist' break; case 5: { JComboBox cbx = createComboBox(); //new ValComboBoxFromQuery(DBTableIdMgr.getInstance().getInfoById(1), "catalogNumber","CatalogNumber","CatalogNumber"," "," "," "," "," ",ValComboBoxFromQuery.CREATE_ALL);// 'QueryCombo' cbx.setEditable(true); cbx.getEditor().setItem(fi.getCaption()); JPanel cPanel = new JPanel(new BorderLayout()); cPanel.add(cbx, BorderLayout.CENTER); cPanel.add(createElipseBtn(), BorderLayout.EAST); comp = cPanel; addLbl = false; break; } case 7: { String uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", fi.getParent().getFormType()); FormInfo subForm = formHash.get(uniqueKey); if (subForm == null) { uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", null); subForm = formHash.get(uniqueKey); } if (subForm != null) { Vector<String> headers = new Vector<String>(); for (int i = 0; i < subForm.getFields().size(); i++) { headers.add(subForm.getFields().get(i).getCaption()); } JPanel p = new JPanel(new BorderLayout()); p.add(UIHelper.createScrollPane(new JTable(new Vector<Vector<Object>>(), headers)), BorderLayout.CENTER); // 'Grid' comp = p; addLbl = false; } break; } case 8: // 'EmbeddedForm' { String uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", fi.getParent().getFormType()); FormInfo subForm = formHash.get(uniqueKey); if (subForm == null) { uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", null); subForm = formHash.get(uniqueKey); } comp = (subForm != null ? createPanel(subForm).getPanel() : new JPanel()); addLbl = fi.getControlTypeNum() != 8; break; } case 9: { comp = createElipseBtn(); break; } case 20: comp = createScrollPane(createTextArea()); // 'Memo' break; case 21: comp = null;//createComboBox(); // 'MenuItem' break; case 46: comp = createTextField("URL"); // 'URL' break; default: if (fi.getDataTypeNum() == 4) { comp = createCheckBox(" "); } else { comp = createTextField(); } } // switch if (comp != null) { String toolTip = "Field: " + fi.getSp5FieldName() + (StringUtils.isNotEmpty(fi.getSp6FieldName()) && fi.getSp6FieldName().equalsIgnoreCase(fi.getSp5FieldName()) ? " Sp6: " + fi.getSp6FieldName() : ""); comp.setToolTipText(toolTip); PanelBuilder pb = new PanelBuilder(new FormLayout("p,1px,f:p:g", "f:p:g,p,f:p:g")); pb.getPanel().setToolTipText(toolTip); pb.getPanel().setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); if (addLbl) { pb.add(createLabel(fi.getCaption()), cc.xy(1, 2)); } pb.add(comp, cc.xy(3, 2)); panel.add(pb.getPanel()); maxWidth = Math.max(maxWidth, fi.getLeft() + fi.getWidth()); maxHeight = Math.max(maxHeight, fi.getTop() + fi.getHeight()); maxCellWidth = Math.max(maxWidth, fi.getCellX() + fi.getCellWidth()); maxCellHeight = Math.max(maxHeight, fi.getCellY() + fi.getCellHeight()); boolean newWay = false; if (newWay) { Rectangle r = fi.getBoundsFromCellDim(); pb.getPanel().setLocation(r.x, r.y); pb.getPanel().setSize(r.width, r.height); } else { pb.getPanel().setLocation(fi.getLeft(), fi.getTop()); pb.getPanel().setSize(fi.getWidth(), fi.getHeight()); } System.out.println("MaxW: " + maxWidth + " " + maxCellWidth); System.out.println("MaxH: " + maxHeight + " " + maxCellHeight); } } boolean newWay = false; if (newWay) { int cw = FormFieldInfo.getSegWidth(); panel.setPreferredSize(new Dimension(maxCellWidth * cw, maxCellHeight * cw)); panel.setSize(new Dimension(maxCellWidth * cw, maxCellHeight * cw)); } else { panel.setPreferredSize(new Dimension(maxWidth, maxHeight)); panel.setSize(new Dimension(maxWidth, maxHeight)); } System.out.println("MaxW: " + maxWidth + " " + maxCellWidth); System.out.println("MaxH: " + maxHeight + " " + maxCellHeight); return new FormPanelInfo(formInfo.getTitle(), panel, maxWidth, maxHeight); }
From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java
/** * Setup General (Control Center) Tab/*from w w w. j av a 2 s . c o m*/ * * @return JPanel for Control Center */ private JPanel setupGeneral() { JPanel generalPanel = new JPanel(); generalPanel.setLayout(new BorderLayout()); /* -- Stats Panel -- */ JPanel statsPanel = new JPanel(); generalPanel.add(statsPanel, BorderLayout.NORTH); statsPanel.setLayout(new GridLayout(0, 2, 10, 10)); JPanel eastPanel = new JPanel(); statsPanel.add(eastPanel, BorderLayout.EAST); eastPanel.setLayout(new BorderLayout()); JPanel westPanel = new JPanel(); statsPanel.add(westPanel, BorderLayout.WEST); westPanel.setLayout(new BorderLayout()); // Grid Information Panel JPanel gridInfoPanel = new JPanel(); eastPanel.add(gridInfoPanel, BorderLayout.NORTH); gridInfoPanel.setBorder(BorderFactory.createTitledBorder("Grid Information")); gridInfoPanel.setLayout(new GridLayout(0, 2, 10, 10)); JLabel nodeIdLabel = new JLabel("Node ID :"); gridInfoPanel.add(nodeIdLabel); JLabel nodeId = new JLabel("#nodeid#"); gridInfoPanel.add(nodeId); addUIElement("general.stats.nodeid", nodeId); // Add to components map JLabel nodeIpLabel = new JLabel("Node IP :"); gridInfoPanel.add(nodeIpLabel); JLabel nodeIp = new JLabel("#nodeip#"); gridInfoPanel.add(nodeIp); addUIElement("general.stats.nodeip", nodeIp); // Add to components map JLabel clusterIdLabel = new JLabel("Cluster ID :"); gridInfoPanel.add(clusterIdLabel); JLabel clusterId = new JLabel("#clusterid#"); gridInfoPanel.add(clusterId); addUIElement("general.stats.clusterid", clusterId); // Add to components map JLabel clusterServiceLabel = new JLabel("Cluster Service :"); gridInfoPanel.add(clusterServiceLabel); JLabel clusterService = new JLabel("#clusterservice#"); gridInfoPanel.add(clusterService); addUIElement("general.stats.clusterservice", clusterService); // Add to components map // Node Status Panel JPanel nodeStatusPanel = new JPanel(); eastPanel.add(nodeStatusPanel, BorderLayout.SOUTH); nodeStatusPanel.setBorder(BorderFactory.createTitledBorder("GridNode Status")); nodeStatusPanel.setLayout(new GridLayout(0, 2, 10, 10)); JLabel statusLabel = new JLabel("Status :"); nodeStatusPanel.add(statusLabel); JLabel status = new JLabel("#status#"); nodeStatusPanel.add(status); addUIElement("general.stats.status", status); // Add to components map JLabel uptimeLabel = new JLabel("Node Up Time :"); nodeStatusPanel.add(uptimeLabel); JLabel uptime = new JLabel("#uptime#"); nodeStatusPanel.add(uptime); addUIElement("general.stats.uptime", uptime); // Add to components map JLabel execTimeLabel = new JLabel("Execution Time :"); nodeStatusPanel.add(execTimeLabel); JLabel execTime = new JLabel("#exectime#"); nodeStatusPanel.add(execTime); addUIElement("general.stats.exectime", execTime); // Add to components map // Execution Statistics Panel JPanel execStatsPanel = new JPanel(); westPanel.add(execStatsPanel, BorderLayout.NORTH); execStatsPanel.setLayout(new GridLayout(0, 2, 10, 10)); execStatsPanel.setBorder(BorderFactory.createTitledBorder("Execution Statistics")); JLabel totalJobsLabel = new JLabel("Total Jobs :"); execStatsPanel.add(totalJobsLabel); JLabel totalJobs = new JLabel("0"); execStatsPanel.add(totalJobs); addUIElement("general.stats.totaljobs", totalJobs); // Add to components map JLabel totalTasksLabel = new JLabel("Total Tasks :"); execStatsPanel.add(totalTasksLabel); JLabel totalTasks = new JLabel("0"); execStatsPanel.add(totalTasks); addUIElement("general.stats.totaltasks", totalTasks); // Add to components map JLabel totalBansLabel = new JLabel("Banments :"); execStatsPanel.add(totalBansLabel); JLabel totalBans = new JLabel("0"); execStatsPanel.add(totalBans); addUIElement("general.stats.totalbans", totalBans); // Add to components map // Execution Active Job Panel JPanel activeJobPanel = new JPanel(); westPanel.add(activeJobPanel, BorderLayout.SOUTH); activeJobPanel.setLayout(new GridLayout(0, 2, 10, 10)); activeJobPanel.setBorder(BorderFactory.createTitledBorder("Active Job")); JLabel jobNameLabel = new JLabel("GridJob Name :"); activeJobPanel.add(jobNameLabel); JLabel jobName = new JLabel("#jobname#"); activeJobPanel.add(jobName); addUIElement("general.stats.jobname", jobName); // Add to components map JLabel durationLabel = new JLabel("Duration :"); activeJobPanel.add(durationLabel); JLabel duration = new JLabel("#duration#"); activeJobPanel.add(duration); addUIElement("general.stats.duration", duration); // Add to components map JLabel tasksLabel = new JLabel("Tasks Executed :"); activeJobPanel.add(tasksLabel); JLabel tasks = new JLabel("#xyz#"); activeJobPanel.add(tasks); addUIElement("general.stats.tasks", tasks); // Add to components map JLabel failuresLabel = new JLabel("Failures :"); activeJobPanel.add(failuresLabel); JLabel failures = new JLabel("#failures#"); activeJobPanel.add(failures); addUIElement("general.stats.failures", failures); // Add to components map /* -- Log Panel -- */ JPanel logPanel = new JPanel(); generalPanel.add(logPanel, BorderLayout.CENTER); logPanel.setLayout(new BorderLayout()); logPanel.setBorder(BorderFactory.createTitledBorder("Log Output")); JTextPane logTextPane = new JTextPane(); logTextPane.setEditable(false); logTextPane.setBackground(Color.BLACK); logTextPane.setForeground(Color.WHITE); logPanel.add(new JScrollPane(logTextPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); addUIElement("general.log", logTextPane); // Add to component map JPanel logOptionsPanel = new JPanel(); logPanel.add(logOptionsPanel, BorderLayout.SOUTH); logOptionsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox logScrollCheckbox = new JCheckBox("Auto-Scroll Log"); logScrollCheckbox.setSelected(true); logScrollCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JTextPaneAppender.setAutoScroll(logScrollCheckbox.isSelected()); } }); logOptionsPanel.add(logScrollCheckbox); // Enable Logging JTextPaneAppender.setTextPane(logTextPane); /* -- Buttons Panel -- */ JPanel buttonsPanel = new JPanel(); generalPanel.add(buttonsPanel, BorderLayout.SOUTH); buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); // Shutdown Button JButton shutdownButton = new JButton("Shutdown"); buttonsPanel.add(shutdownButton); shutdownButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doShutdownNode(); } }); // Start Up time Thread Thread t = new Thread(new Runnable() { public void run() { long start = System.currentTimeMillis(); while (true) { try { Thread.sleep(1000); } catch (InterruptedException e) { log.warn("Interrupted Exception in Up Time Thread", e); } final String uptime = TimeUtils.timeDifference(start); SwingUtilities.invokeLater(new Runnable() { public void run() { JLabel upTime = getUIElement("general.stats.uptime"); upTime.setText(uptime); } }); } } }); t.setDaemon(true); t.start(); // Auto-Discovery Thread Thread autoDiscovery = new Thread(new Runnable() { public void run() { while (true) { try { // Attempt every 30 seconds Thread.sleep(30000); } catch (InterruptedException e) { log.warn("Interrupted Exception in Up Time Thread", e); } if (autodiscover && (!Grid.isNode())) { // 30 Second Intervals doDiscover(true); } } } }); autoDiscovery.setDaemon(true); autoDiscovery.start(); return generalPanel; }
From source file:LayeredPaneDemo2.java
protected void createTitleBar() { m_titlePanel = new JPanel() { public Dimension getPreferredSize() { return new Dimension(InnerFrame.this.getWidth(), m_titleBarHeight); }// w w w . j a va 2s .c o m }; m_titlePanel.setLayout(new BorderLayout()); m_titlePanel.setOpaque(true); m_titlePanel.setBackground(TITLE_BAR_BG_COLOR); m_titleLabel = new JLabel(); m_titleLabel.setForeground(Color.black); m_close = new InnerFrameButton(CLOSE_BUTTON_ICON); m_close.setPressedIcon(PRESS_CLOSE_BUTTON_ICON); m_close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { InnerFrame.this.close(); } }); m_maximize = new InnerFrameButton(MAXIMIZE_BUTTON_ICON); m_maximize.setPressedIcon(PRESS_MAXIMIZE_BUTTON_ICON); m_maximize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { InnerFrame.this.setMaximized(!InnerFrame.this.isMaximized()); } }); m_iconize = new InnerFrameButton(ICONIZE_BUTTON_ICON); m_iconize.setPressedIcon(PRESS_ICONIZE_BUTTON_ICON); m_iconize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { InnerFrame.this.setIconified(!InnerFrame.this.isIconified()); } }); m_buttonWrapperPanel = new JPanel(); m_buttonWrapperPanel.setOpaque(false); m_buttonPanel = new JPanel(new GridLayout(1, 3)); m_buttonPanel.setOpaque(false); m_buttonPanel.add(m_iconize); m_buttonPanel.add(m_maximize); m_buttonPanel.add(m_close); m_buttonPanel.setAlignmentX(0.5f); m_buttonPanel.setAlignmentY(0.5f); m_buttonWrapperPanel.add(m_buttonPanel); m_iconLabel = new JLabel(); m_iconLabel.setBorder( new EmptyBorder(FRAME_ICON_PADDING, FRAME_ICON_PADDING, FRAME_ICON_PADDING, FRAME_ICON_PADDING)); if (m_frameIcon != null) m_iconLabel.setIcon(m_frameIcon); m_titlePanel.add(m_titleLabel, BorderLayout.CENTER); m_titlePanel.add(m_buttonWrapperPanel, BorderLayout.EAST); m_titlePanel.add(m_iconLabel, BorderLayout.WEST); InnerFrameTitleBarMouseAdapter iftbma = new InnerFrameTitleBarMouseAdapter(this); m_titlePanel.addMouseListener(iftbma); m_titlePanel.addMouseMotionListener(iftbma); }
From source file:com.floreantpos.ui.views.SwitchboardView.java
private JPanel createActivityPanel() { JPanel activityPanel = new JPanel(new BorderLayout(5, 5)); JPanel innerActivityPanel = new JPanel(new MigLayout("hidemode 3, fill, ins 0", "fill, grow", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JPanel firstRowButtonPanel = new JPanel(new GridLayout(1, 0, 5, 5)); final JXCollapsiblePane secondRowButtonPanel = new JXCollapsiblePane(); secondRowButtonPanel.setAnimated(false); secondRowButtonPanel.setCollapsed(true); secondRowButtonPanel.setVisible(false); secondRowButtonPanel.getContentPane().setLayout(new GridLayout(1, 0, 5, 5)); if (Application.getInstance().getTerminal().isHasCashDrawer()) { firstRowButtonPanel.add(btnOrderInfo); firstRowButtonPanel.add(btnEditTicket); firstRowButtonPanel.add(btnSettleTicket); firstRowButtonPanel.add(btnGroupSettle); firstRowButtonPanel.add(btnCloseOrder); secondRowButtonPanel.getContentPane().add(btnSplitTicket); secondRowButtonPanel.getContentPane().add(btnReopenTicket); secondRowButtonPanel.getContentPane().add(btnVoidTicket); secondRowButtonPanel.getContentPane().add(btnRefundTicket); secondRowButtonPanel.getContentPane().add(btnAssignDriver); } else {//from www. j a va2 s . c om firstRowButtonPanel.add(btnOrderInfo); firstRowButtonPanel.add(btnEditTicket); firstRowButtonPanel.add(btnCloseOrder); firstRowButtonPanel.add(btnSplitTicket); secondRowButtonPanel.getContentPane().add(btnReopenTicket); secondRowButtonPanel.getContentPane().add(btnVoidTicket); secondRowButtonPanel.getContentPane().add(btnRefundTicket); secondRowButtonPanel.getContentPane().add(btnAssignDriver); } innerActivityPanel.add(firstRowButtonPanel); innerActivityPanel.add(secondRowButtonPanel, "newline"); //$NON-NLS-1$ final PosButton btnMore = new PosButton(POSConstants.MORE_ACTIVITY_BUTTON_TEXT); btnMore.setPreferredSize(new Dimension(PosUIManager.getSize(78), 0)); btnMore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean collapsed = secondRowButtonPanel.isCollapsed(); secondRowButtonPanel.setVisible(collapsed); secondRowButtonPanel.setCollapsed(!collapsed); if (collapsed) { btnMore.setText(POSConstants.LESS_ACTIVITY_BUTTON_TEXT); } else { btnMore.setText(POSConstants.MORE_ACTIVITY_BUTTON_TEXT); } } }); activityPanel.add(innerActivityPanel); activityPanel.add(btnMore, BorderLayout.EAST); return activityPanel; }
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
/** * * * @param application//from ww w . ja v a2 s . c o m * * @throws SshToolsApplicationException */ public void init(SshToolsApplication application) throws SshToolsApplicationException { super.init(application); // Additional connection tabs additionalTabs = new SshToolsConnectionTab[] { new SshTermTerminalTab() }; // Printing page format try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new RuntimePermission("queuePrintJob")); } try { PrinterJob job = PrinterJob.getPrinterJob(); if (job == null) { throw new IOException("Could not get print page format."); } pageFormat = job.defaultPage(); if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) { pageFormat.setOrientation( PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE)); Paper paper = new Paper(); paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0)); paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0)); pageFormat.setPaper(paper); } } catch (Exception e) { showExceptionMessage("Error", e.getMessage()); } } catch (AccessControlException ace) { ace.printStackTrace(); } enableEvents(VDU_EVENTS); // Set up the actions initActions(); // Create the status bar statusBar = new StatusBar(); dataListener = new DataNotificationListener(statusBar); // Create our terminal emulation object try { emulation = createEmulation(); } catch (IOException ioe) { throw new SshToolsApplicationException(ioe); } emulation.addTerminalListener(this); // Set a scrollbar for the terminal - doesn't seem to be as simple as this scrollBar = new JScrollBar(JScrollBar.VERTICAL); emulation.setBufferSize(1000); // Create our swing terminal and add it to the main frame terminal = new TerminalPanel(emulation) { public void processEvent(AWTEvent evt) { /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */ if (evt instanceof MouseEvent && evt.getID() == 507) { try { Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {}); SshTermSessionPanel.this.scrollBar.setValue(SshTermSessionPanel.this.scrollBar.getValue() + (SshTermSessionPanel.this.scrollBar.getUnitIncrement() * ((Integer) m.invoke(evt, new Object[] {})).intValue() * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1))); } catch (Throwable t) { } } else { super.processEvent(evt); } } public void copyNotify() { copyAction.actionPerformed(null); } }; terminal.requestFocus(); terminal.setScrollbar(scrollBar); terminal.addMouseMotionListener(this); //terminal.addMouseWheelListener(this); // Center panel with terminal and scrollbar JPanel center = new JPanel(new BorderLayout()); center.setBackground(Color.red); center.add(terminal, BorderLayout.CENTER); center.add(scrollBar, BorderLayout.EAST); // Show the context menu on mouse button 3 (right click) terminal.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) { getContextMenu().setLabel(getApplication().getApplicationName()); getContextMenu().show(terminal, evt.getX(), evt.getY()); } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) { pasteAction.actionPerformed(null); } } }); // // JPanel top = new JPanel(new BorderLayout()); // top.add(getJMenuBar(), BorderLayout.NORTH); // top.add(north, BorderLayout.SOUTH); setLayout(new BorderLayout()); add(center, BorderLayout.CENTER); // add(top, BorderLayout.NORTH); // Make sure that the swing terminal has focus terminal.requestFocus(); }
From source file:org.ut.biolab.medsavant.client.view.variants.BrowserPage.java
@Override public JPanel getView() { try {//from w ww. ja va2 s . com if (view == null) { trackAdditionLock.acquire(); view = new JPanel(); view.setLayout(new BorderLayout()); view.add(new WaitPanel("Starting Genome Browser")); Chromosome[] chroms = MedSavantClient.ReferenceManager.getChromosomes( LoginController.getSessionID(), ReferenceController.getInstance().getCurrentReferenceID()); genomeContainer = new GenomeContainer(pageName, chroms); genomeView = new PeekingPanel("Genome", BorderLayout.SOUTH, genomeContainer, false, 225); final JPanel variationPlaceHolder = new JPanel(); variationPlaceHolder.setLayout(new BorderLayout()); variationPlaceHolder.add(new WaitPanel("Initializing variant views..."), BorderLayout.CENTER); variationPanel = new PeekingPanel("Variations", BorderLayout.WEST, variationPlaceHolder, false, 325); variationPanel.setToggleBarVisible(false); Runnable prepareBrowserThread = new Runnable() { @Override public void run() { try { final JPanel tmpView = new JPanel(); tmpView.setLayout(new BorderLayout()); genomeView.setToggleBarVisible(false); tmpView.add(genomeView, BorderLayout.NORTH); browserPanel = new JPanel(); browserPanel.setLayout(new BorderLayout()); Savant savantInstance = Savant.getInstance(false, false); setupToolbarButtons(savantInstance); PersistentSettings.getInstance().setColor(ColourKey.GRAPH_PANE_BACKGROUND_BOTTOM, Color.white); PersistentSettings.getInstance().setColor(ColourKey.GRAPH_PANE_BACKGROUND_TOP, Color.white); PersistentSettings.getInstance().setColor(ColourKey.AXIS_GRID, new Color(240, 240, 240)); savantInstance.setStartPageVisible(false); savantInstance.setTrackBackground(new Color(210, 210, 210)); savantInstance.setBookmarksVisibile(false); savantInstance.setVariantsVisibile(false); variationPlaceHolder.removeAll(); variationPlaceHolder.add(VariationController.getInstance().getModule(), BorderLayout.CENTER); GenomeController.getInstance().setGenome(null); String referenceName = ReferenceController.getInstance().getCurrentReferenceName(); final String urlOfTrack = getTrackURL(referenceName, "sequence"); browserPanel.add(savantInstance.getBrowserPanel(), BorderLayout.CENTER); tmpView.add(browserPanel, BorderLayout.CENTER); tmpView.add(variationPanel, BorderLayout.EAST); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { view.removeAll(); view.add(tmpView, BorderLayout.CENTER); view.updateUI(); } }); Thread t = new Thread(new Runnable() { @Override public void run() { addTrackFromURLString(urlOfTrack, DataFormat.SEQUENCE); trackAdditionLock.release(); } }); t.start(); } catch (Exception ex) { LOG.error("Got exception: " + ex); } } }; new Thread(prepareBrowserThread).start(); } else { if (genomeContainer != null) { genomeContainer.updateIfRequired(); } } } catch (Exception ex) { ClientMiscUtils.reportError("Error generating genome view: %s", ex); } return view; }
From source file:edu.uci.ics.jung.samples.PerspectiveVertexImageShaperDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features.//from w w w.ja va 2s . co m * */ @SuppressWarnings("serial") public PerspectiveVertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseMultigraph<Number, Number>(); Number[] vertices = createVertices(11); // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < vertices.length; i++) { map.put(vertices[i], iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < vertices.length; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(PerspectiveVertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(vertices[i], icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } createEdges(vertices); final VertexStringerImpl<Number> vertexStringerImpl = new VertexStringerImpl<Number>(map); final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); vv.setBackground(Color.decode("0xffffdd")); final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); vv.addPostRenderPaintable(new VisualizationServer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); this.viewSupport = new PerspectiveImageLensSupport<Number, Number>(vv); this.layoutSupport = new PerspectiveLayoutTransformSupport<Number, Number>(vv); 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, 0.9f, vv.getCenter()); } }); final JSlider horizontalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(80, super.getPreferredSize().height); } }; final JSlider verticalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, 80); } }; verticalSlider.setOrientation(JSlider.VERTICAL); final ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { int vval = -verticalSlider.getValue(); int hval = horizontalSlider.getValue(); Dimension d = vv.getSize(); PerspectiveTransform pt = null; pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval, d.height + hval, -vval, d.height - hval, 0, 0, d.width, 0, d.width, d.height, 0, d.height); viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); vv.repaint(); } }; horizontalSlider.addChangeListener(changeListener); verticalSlider.addChangeListener(changeListener); JPanel perspectivePanel = new JPanel(new BorderLayout()); JPanel perspectiveCenterPanel = new JPanel(new BorderLayout()); perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls")); final JButton center = new JButton("Center"); center.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { horizontalSlider.setValue(0); verticalSlider.setValue(0); } }); final JCheckBox noText = new JCheckBox("No Text"); noText.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { JCheckBox cb = (JCheckBox) e.getSource(); vertexStringerImpl.setEnabled(!cb.isSelected()); vv.repaint(); } }); JPanel centerPanel = new JPanel(); centerPanel.add(noText); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange() == ItemEvent.SELECTED; if (selected) { if (viewSupport != null) { viewSupport.deactivate(); } if (layoutSupport != null) { layoutSupport.deactivate(); } } center.setEnabled(!selected); horizontalSlider.setEnabled(!selected); verticalSlider.setEnabled(!selected); } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); panel.setCorner(menubar); JPanel scaleGrid = new JPanel(new GridLayout(2, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(new BorderLayout()); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid, BorderLayout.WEST); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); perspectivePanel.add(lensPanel, BorderLayout.WEST); perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH); perspectivePanel.add(verticalSlider, BorderLayout.EAST); perspectiveCenterPanel.add(center); perspectivePanel.add(perspectiveCenterPanel); controls.add(perspectivePanel, BorderLayout.EAST); controls.add(centerPanel); content.add(controls, BorderLayout.SOUTH); }
From source file:io.github.jeremgamer.editor.panels.MusicFrame.java
public MusicFrame(JFrame frame, final GeneralSave gs) { ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>(); try {/* w w w. j a v a 2 s . c o m*/ icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png"))); } catch (IOException e1) { e1.printStackTrace(); } this.setIconImages((List<? extends Image>) icons); this.setTitle("Musique"); this.setSize(new Dimension(300, 225)); this.addWindowListener(new WindowListener() { @Override public void windowActivated(WindowEvent event) { } @Override public void windowClosed(WindowEvent event) { } @Override public void windowClosing(WindowEvent event) { try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } @Override public void windowDeactivated(WindowEvent event) { } @Override public void windowDeiconified(WindowEvent event) { } @Override public void windowIconified(WindowEvent event) { } @Override public void windowOpened(WindowEvent event) { } }); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); this.setModal(true); this.setLocationRelativeTo(frame); JPanel properties = new JPanel(); properties.setBorder(BorderFactory.createTitledBorder("Lecture")); ButtonGroup bg = new ButtonGroup(); bg.add(one); bg.add(loop); one.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JRadioButton rb = (JRadioButton) event.getSource(); if (rb.isSelected()) { gs.set("music.reading", 0); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { if (clip.isRunning()) clip.loop(0); } } } }); loop.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JRadioButton rb = (JRadioButton) event.getSource(); if (rb.isSelected()) { gs.set("music.reading", 1); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { if (clip.isRunning()) clip.loop(Clip.LOOP_CONTINUOUSLY); } } } }); properties.add(one); properties.add(loop); if (gs.getInt("music.reading") == 0) { one.setSelected(true); } else { loop.setSelected(true); } volume.setMaximum(100); volume.setMinimum(0); volume.setValue(30); volume.setPaintTicks(true); volume.setPaintLabels(true); volume.setMinorTickSpacing(10); volume.setMajorTickSpacing(20); volume.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { JSlider slider = (JSlider) event.getSource(); double value = slider.getValue(); gain = value / 100; dB = (float) (Math.log(gain) / Math.log(10.0) * 20.0); if (clip != null) gainControl.setValue(dB); gs.set("music.volume", (int) value); } }); volume.setValue(gs.getInt("music.volume")); properties.add(volume); properties.setPreferredSize(new Dimension(300, 125)); content.add(properties); JPanel browsePanel = new JPanel(); browsePanel.setBorder(BorderFactory.createTitledBorder("")); JButton browse = new JButton("Parcourir..."); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { preview.setEnabled(false); browse.setText(""); try { browse.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } } browse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JButton button = (JButton) event.getSource(); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { if (clip != null) { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } name.setText(""); preview.setEnabled(false); button.setText("Parcourir..."); button.setIcon(null); new File("projects/" + Editor.getProjectName() + "/music.wav").delete(); gs.set("music.name", ""); } else { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Audio (WAV)", "wav"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyMusic(new File(path)); button.setText(""); try { button.setIcon( new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } gs.set("music.name", new File(path).getName()); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } name.setText(new File(path).getName()); preview.setEnabled(true); } } } }); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { preview.setEnabled(true); } else { preview.setEnabled(false); } preview.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JToggleButton tb = (JToggleButton) event.getSource(); if (tb.isSelected()) { try { audioStream = AudioSystem.getAudioInputStream( new File("projects/" + Editor.getProjectName() + "/music.wav")); format = audioStream.getFormat(); info = new DataLine.Info(Clip.class, format); clip = (Clip) AudioSystem.getLine(info); clip.open(audioStream); clip.start(); gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); gainControl.setValue(dB); if (loop.isSelected()) { clip.loop(Clip.LOOP_CONTINUOUSLY); } else { clip.loop(0); } clip.addLineListener(new LineListener() { @Override public void update(LineEvent event) { Clip clip = (Clip) event.getSource(); if (!clip.isRunning()) { preview.setSelected(false); clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }); } catch (Exception exc) { exc.printStackTrace(); } } else { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BorderLayout()); buttons.add(browse, BorderLayout.WEST); buttons.add(preview, BorderLayout.EAST); browsePanel.setLayout(new BorderLayout()); browsePanel.add(buttons, BorderLayout.NORTH); browsePanel.add(name, BorderLayout.SOUTH); name.setPreferredSize(new Dimension(280, 25)); name.setText(gs.getString("music.name")); content.add(browsePanel); this.setContentPane(content); this.setVisible(true); }
From source file:org.paxle.desktop.impl.dialogues.cconsole.CrawlingConsole.java
private void init(final MWComponents comp, final boolean showEnqueued, final boolean showDestroyed) { scroll.setViewportView(table);//from w w w .j a v a 2s . co m updateCpb(false, true, false); cbEnq.setSelected(showEnqueued); cbDstr.setSelected(showDestroyed); cbox.setActionCommand(AC_SELECT); cbox.setSelectedIndex(comp.ordinal()); final JPanel bbLeft = new JPanel(new FlowLayout(FlowLayout.LEFT)); bbLeft.add(cpb); bbLeft.add(cbox); bbLeft.add(cbEnq); bbLeft.add(cbDstr); final JPanel bbRight = new JPanel(new FlowLayout(FlowLayout.RIGHT)); clear.setEnabled(false); bbRight.add(Utilities.instance.setButtonProps(new JToggleButton(), "\u2193 " + Messages.getString("crawlingConsole.settings"), this, AC_SETTINGS, KeyEvent.VK_S, null)); bbRight.add(clear); final JPanel b = new JPanel(new BorderLayout()); b.add(bbLeft, BorderLayout.WEST); b.add(bbRight, BorderLayout.EAST); options.setVisible(false); b.add(options, BorderLayout.SOUTH); super.setLayout(new BorderLayout()); super.add(scroll, BorderLayout.CENTER); super.add(b, BorderLayout.SOUTH); }
From source file:org.rdv.viz.image.ImageViz.java
private void initIrisControls() { irisControls = new JPanel(); irisControls.setLayout(new BorderLayout()); JButton closeIrisButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-close.gif")); closeIrisButton.setBorder(null);/*from w w w.ja va 2 s . c om*/ closeIrisButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { irisClose(); } }); irisControls.add(closeIrisButton, BorderLayout.WEST); JButton irisControlButton = new StrechIconButton( DataViewer.getIcon("icons/ptz/robotic_control-irisbar-medium.gif")); irisControlButton.setBorder(null); irisControlButton.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { JButton button = (JButton) e.getComponent(); int iris = Math.round(100f * e.getPoint().x / button.getWidth()); iris(iris); } }); irisControls.add(irisControlButton, BorderLayout.CENTER); JPanel irisControlsRight = new JPanel(); irisControlsRight.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); JButton openIrisButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-open.gif")); openIrisButton.setBorder(null); openIrisButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { irisOpen(); } }); irisControlsRight.add(openIrisButton); JButton autoIrisButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-auto.gif")); autoIrisButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { irisAuto(); } }); autoIrisButton.setBorder(null); irisControlsRight.add(autoIrisButton); irisControls.add(irisControlsRight, BorderLayout.EAST); }