List of usage examples for javax.swing SwingConstants WEST
int WEST
To view the source code for javax.swing SwingConstants WEST.
Click Source Link
From source file:op.care.values.PnlValues.java
private JPanel createContentPanel4Year(final ResValueTypes vtype, final int year) { final String keyYears = vtype.getID() + ".xtypes." + Integer.toString(year) + ".year"; java.util.List<ResValue> myValues; synchronized (mapType2Values) { if (!mapType2Values.containsKey(keyYears)) { mapType2Values.put(keyYears, ResValueTools.getResValues(resident, vtype, year)); }/*from w ww . j a v a2 s . c o m*/ if (mapType2Values.get(keyYears).isEmpty()) { JLabel lbl = new JLabel(SYSTools.xx("misc.msg.novalue")); JPanel pnl = new JPanel(); pnl.add(lbl); return pnl; } myValues = mapType2Values.get(keyYears); } JPanel pnlYear = new JPanel(new VerticalLayout()); pnlYear.setOpaque(false); for (final ResValue resValue : myValues) { String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"200\" align=\"left\">" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT).format(resValue.getPit()) + " [" + resValue.getID() + "]</td>" + "<td width=\"340\" align=\"left\">" + ResValueTools.getValueAsHTML(resValue) + "</td>" + "<td width=\"200\" align=\"left\">" + resValue.getUser().getFullname() + "</td>" + "</tr>" + "</table>" + "</html>"; final DefaultCPTitle pnlTitle = new DefaultCPTitle(title, null); pnlTitle.getMain().setBackground(GUITools.blend(vtype.getColor(), Color.WHITE, 0.1f)); pnlTitle.getMain().setOpaque(true); if (resValue.isObsolete()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22eraser)); } if (resValue.isReplacement()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22edited)); } if (!resValue.getText().trim().isEmpty()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22info)); } if (pnlTitle.getAdditionalIconPanel().getComponentCount() > 0) { pnlTitle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup( GUITools.getHTMLPopup(pnlTitle.getButton(), ResValueTools.getInfoAsHTML(resValue)), SwingConstants.NORTH); } }); } if (!resValue.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(resValue.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } }); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlTitle.getRight().add(btnFiles); } if (!resValue.getAttachedProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(resValue.getAttachedProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getResValue().getAttachedProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlTitle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(resValue); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!resValue.isObsolete()); pnlTitle.getRight().add(btnMenu); pnlYear.add(pnlTitle.getMain()); synchronized (linemap) { linemap.put(resValue, pnlTitle.getMain()); } } return pnlYear; }
From source file:org.drugis.addis.gui.components.progressgraph.ProgressGraph.java
public JPanel createPanel() { final FormLayout layout = new FormLayout(createFormSpec("pref", d_numCols), "p, " + createFormSpec("3dlu, p", d_numTotalRows - 1)); CellConstraints cc = new CellConstraints(); JPanel progressPanel = new JPanel(layout); Dimension cellSize = new Dimension(d_edgeLength, d_arrowSize); Dimension circleSize = new Dimension(d_circleDiameter, d_circleDiameter); for (int i = 0; i < d_numberOfChains; ++i) { int rowIdx = (2 * i) + 1; Task tuningTask = d_model.getModel().getActivityTask().getModel() .getStateByName(MCMCModel.TUNING_CHAIN_PREFIX + i); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), cc.xy(6, rowIdx)); progressPanel.add(new GraphProgressNode(d_gridCellSize, tuningTask), cc.xy(7, rowIdx)); Task simulationTask = d_model.getModel().getActivityTask().getModel() .getStateByName(MCMCModel.SIMULATION_CHAIN_PREFIX + i); progressPanel.add(new GraphLine(new Dimension(d_edgeLength * 2, d_arrowSize), 2, SwingConstants.EAST), cc.xy(9, rowIdx));/*ww w . j av a2s . c o m*/ progressPanel.add(new GraphProgressNode(d_gridCellSize, simulationTask), cc.xy(10, rowIdx)); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), cc.xy(11, rowIdx)); } /** Placement needed for the calculated preferred size */ progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.START), centerCell(cc, d_numMainRows, 1)); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 2)); Task startTask = d_model.getModel().getActivityTask().getModel() .getStateByName(MCMCModel.STARTING_SIMULATION_PHASE); progressPanel.add(new GraphProgressNode(d_gridCellSize, startTask, false), centerCell(cc, d_numMainRows, 3)); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 4)); //NOTE: it is a mystery why numMainRows - 1 is the correct count instead of just numMainRows progressPanel.add( new GraphBar(new Dimension(d_barWidth, (int) progressPanel.getPreferredSize().getHeight())), centerCell(cc, d_numMainRows - 1, 5)); progressPanel.add( new GraphBar(new Dimension(d_barWidth, (int) progressPanel.getPreferredSize().getHeight())), centerCell(cc, d_numMainRows - 1, 12)); Task assessConvergence = d_model.getModel().getActivityTask().getModel() .getStateByName(MCMCModel.CALCULATING_SUMMARIES_PHASE); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 13)); progressPanel.add(new GraphProgressNode(d_gridCellSize, assessConvergence, false), centerCell(cc, d_numMainRows, 14)); progressPanel.add(new GraphLine(new Dimension(d_arrowSize, 50), 2, SwingConstants.SOUTH), cc.xywh(14, d_numMainRows / 2 + 2, 1, d_numMainRows / 2 + 1, CellConstraints.CENTER, CellConstraints.BOTTOM)); progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.DECISION), cc.xywh(14, d_numMainRows + 2, 1, 1, CellConstraints.CENTER, CellConstraints.CENTER)); progressPanel.add( new GraphLine(new Dimension((int) (d_edgeLength + (d_edgeLength)), d_arrowSize), 2, SwingConstants.EAST), cc.xyw(14, d_numMainRows + 2, 2, CellConstraints.RIGHT, CellConstraints.DEFAULT)); progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.END), cc.xy(16, d_numMainRows + 2)); progressPanel.add(new GraphLine(new Dimension(d_edgeLength * 9, d_arrowSize), 2, SwingConstants.WEST), cc.xyw(10, d_numMainRows + 2, 14 - 7, CellConstraints.LEFT, CellConstraints.DEFAULT)); progressPanel.add(new GraphBar(new Dimension(d_edgeLength * 2, d_barWidth)), cc.xy(9, d_numMainRows + 2)); int totalHeight = (int) progressPanel.getPreferredSize().getHeight(); progressPanel.add( new GraphConnector(new Dimension(d_edgeLength * 2, totalHeight), d_cellHeight + Sizes.DLUY3.getPixelSize(progressPanel), totalHeight - 30, d_numberOfChains), cc.xywh(9, 1, 1, d_numTotalRows)); PanelBuilder builder = new PanelBuilder(new FormLayout("pref", "p")); builder.setDefaultDialogBorder(); builder.add(progressPanel); return builder.getPanel(); }
From source file:org.executequery.base.DockedTabContainer.java
protected int getTabPanePosition(DockedTabPane tabPane) { if (tabPane == northTabPane) { if (orientation == SwingConstants.WEST) { return SwingConstants.NORTH_WEST; } else {/*from w w w . j a v a2 s .c o m*/ return SwingConstants.NORTH_EAST; } } else if (tabPane == southTabPane) { if (orientation == SwingConstants.WEST) { return SwingConstants.SOUTH_WEST; } else if (orientation == SwingConstants.CENTER) { return SwingConstants.SOUTH; } else { return SwingConstants.SOUTH_EAST; } } return SwingConstants.NORTH_WEST; // default }
From source file:org.zaproxy.zap.extension.callgraph.CallGraphFrame.java
private void setupFrame() { // define a visual layout on the graph mxHierarchicalLayout layout = new com.mxgraph.layout.hierarchical.mxHierarchicalLayout(graph, SwingConstants.WEST); final mxGraphComponent graphComponent = new mxGraphComponent(graph); graphComponent.setConnectable(false); graphComponent.setToolTips(true);//from www.j a va2 s. c o m graphComponent.setAutoExtend(true); graphComponent.setAutoScroll(true); // add the graph component to the frame in the centre. getContentPane().add(graphComponent, BorderLayout.CENTER); // and set up a panel below that JPanel toolBar = new JPanel(); toolBar.setLayout(new BorderLayout()); // with an outline of the graph, and have it settle in the west.. final mxGraphOutline graphOutline = new mxGraphOutline(graphComponent); graphOutline.setPreferredSize(new Dimension(100, 100)); toolBar.add(graphOutline, BorderLayout.WEST); // and some buttons in the panel JPanel buttonBar = new JPanel(); buttonBar.setLayout(new FlowLayout()); // zoom to fit button JButton btZoomToFit = new JButton(Constant.messages.getString("callgraph.button.zoomfit")); btZoomToFit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { double newScale = 1; Dimension graphSize = graphComponent.getGraphControl().getSize(); Dimension viewPortSize = graphComponent.getViewport().getSize(); int gw = (int) graphSize.getWidth(); int gh = (int) graphSize.getHeight(); if (gw > 0 && gh > 0) { int w = (int) viewPortSize.getWidth(); int h = (int) viewPortSize.getHeight(); newScale = Math.min((double) w / gw, (double) h / gh); } graphComponent.zoomTo(newScale, true); } }); buttonBar.add(btZoomToFit); // center graph JButton btCenter = new JButton(Constant.messages.getString("callgraph.button.centregraph")); btCenter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Dimension graphSize = graphComponent.getGraphControl().getSize(); Dimension viewPortSize = graphComponent.getViewport().getSize(); int x = graphSize.width / 2 - viewPortSize.width / 2; int y = graphSize.height / 2 - viewPortSize.height / 2; int w = viewPortSize.width; int h = viewPortSize.height; graphComponent.getGraphControl().scrollRectToVisible(new Rectangle(x, y, w, h)); } }); buttonBar.add(btCenter); // add a rubberband zoom on the mouse selection event new mxRubberband(graphComponent) { public void mouseReleased(MouseEvent e) { // get bounds before they are reset Rectangle rect = bounds; // invoke usual behaviour super.mouseReleased(e); if (rect != null) { double newScale = 1; Dimension graphSize = new Dimension(rect.width, rect.height); Dimension viewPortSize = graphComponent.getViewport().getSize(); int gw = (int) graphSize.getWidth(); int gh = (int) graphSize.getHeight(); if (gw > 0 && gh > 0) { int w = (int) viewPortSize.getWidth(); int h = (int) viewPortSize.getHeight(); newScale = Math.min((double) w / gw, (double) h / gh); } // zoom to fit the selected area on screen graphComponent.zoom(newScale); // make the selected area visible graphComponent.getGraphControl() .scrollRectToVisible(new Rectangle((int) (rect.x * newScale), (int) (rect.y * newScale), (int) (rect.width * newScale), (int) (rect.height * newScale))); } } }; // put the components on frame toolBar.add(buttonBar, BorderLayout.CENTER); getContentPane().add(toolBar, BorderLayout.SOUTH); // TODO: Do we need this here? // frame.setVisible(true); // lay it out graph.getModel().beginUpdate(); try { layout.execute(graph.getDefaultParent()); } finally { graph.getModel().endUpdate(); } // setDefaultCloseOperation(JFrame.); // setSize(400, 400); pack(); setVisible(true); }
From source file:unikn.dbis.univis.visualization.graph.VGraph.java
/** * @param source Source where the edge is starting. * @param target Target where the edge is ending. *///from ww w .ja v a 2 s . co m public void createEdges(VGraphCell source, VGraphCell target) { DefaultEdge edge = new DefaultEdge(); if (layout.getOrientation() == SwingConstants.NORTH) { edge.setSource(source.getChildAt(1)); edge.setTarget(target.getChildAt(0)); } else if (layout.getOrientation() == SwingConstants.WEST) { edge.setSource(source.getChildAt(3)); edge.setTarget(target.getChildAt(2)); } else if (layout.getOrientation() == SwingConstants.SOUTH) { edge.setSource(source.getChildAt(0)); edge.setTarget(target.getChildAt(1)); } else if (layout.getOrientation() == SwingConstants.EAST) { edge.setSource(source.getChildAt(2)); edge.setTarget(target.getChildAt(3)); } GraphConstants.setLineEnd(edge.getAttributes(), GraphConstants.ARROW_CLASSIC); GraphConstants.setEndFill(edge.getAttributes(), true); cache.insert(edge); }
From source file:unikn.dbis.univis.visualization.graph.VGraph.java
public void rotateRight() { if ((SwingConstants.NORTH) == getLayoutOrientation()) { setLayoutOrientation(SwingConstants.EAST); } else if ((SwingConstants.EAST) == getLayoutOrientation()) { setLayoutOrientation(SwingConstants.SOUTH); } else if ((SwingConstants.SOUTH) == getLayoutOrientation()) { setLayoutOrientation(SwingConstants.WEST); } else if ((SwingConstants.WEST) == getLayoutOrientation()) { setLayoutOrientation(SwingConstants.NORTH); }//from w w w . j ava 2s .c om rotateGraph(); }
From source file:unikn.dbis.univis.visualization.graph.VGraph.java
public void rotateLeft() { if ((SwingConstants.NORTH) == getLayoutOrientation()) { setLayoutOrientation(SwingConstants.WEST); } else if ((SwingConstants.WEST) == getLayoutOrientation()) { setLayoutOrientation(SwingConstants.SOUTH); } else if ((SwingConstants.SOUTH) == getLayoutOrientation()) { setLayoutOrientation(SwingConstants.EAST); } else if ((SwingConstants.EAST) == getLayoutOrientation()) { setLayoutOrientation(SwingConstants.NORTH); }/*from w w w. ja v a 2s.co m*/ rotateGraph(); }