Example usage for javax.swing BorderFactory createCompoundBorder

List of usage examples for javax.swing BorderFactory createCompoundBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createCompoundBorder.

Prototype

public static CompoundBorder createCompoundBorder(Border outsideBorder, Border insideBorder) 

Source Link

Document

Creates a compound border specifying the border objects to use for the outside and inside edges.

Usage

From source file:org.jfree.chart.demo.SuperDemo.java

private JPanel createChartDisplayPanel() {
    displayPanel = new JPanel(new BorderLayout());
    chartContainer = new JPanel(new BorderLayout());
    chartContainer.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    chartContainer.add(createNoDemoSelectedPanel());
    descriptionContainer = new JPanel(new BorderLayout());
    descriptionContainer.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    descriptionContainer.setPreferredSize(new Dimension(600, 140));
    descriptionPane = new JTextPane();
    descriptionPane.setEditable(false);/*  w w  w  .j  a  v a  2s . c  o  m*/
    JScrollPane jscrollpane = new JScrollPane(descriptionPane, 20, 31);
    descriptionContainer.add(jscrollpane);
    displayDescription("select.html");
    JSplitPane jsplitpane = new JSplitPane(0);
    jsplitpane.setTopComponent(chartContainer);
    jsplitpane.setBottomComponent(descriptionContainer);
    displayPanel.add(jsplitpane);
    jsplitpane.setDividerLocation(0.75D);
    return displayPanel;
}

From source file:edu.ku.brc.specify.tasks.subpane.LocalityMapperSubPane.java

/**
 *
 *//*from   w  ww . ja v a2s  .c  o  m*/
protected void createUI() {
    kmlGen = new CollectingEventLocalityKMLGenerator();
    this.collectingEvents = new ArrayList<CollectingEvent>();

    CollectingEvent startCE = null;
    CollectingEvent endCE = null;

    Vector<Locality> localities = new Vector<Locality>();
    Vector<String> labels = new Vector<String>();
    for (Object obj : colEvents) {
        CollectingEvent collectingEvent = (CollectingEvent) obj;

        Locality locality = collectingEvent.getLocality();
        if (locality == null || locality.getLatitude1() == null || locality.getLongitude1() == null) {
            continue;
        }

        collectingEvents.add(collectingEvent);
        kmlGen.addDataObj(collectingEvent, "");

        if (collectingEvents.size() == 1) {
            startCE = collectingEvent;
            endCE = collectingEvent;
        }
        // XXX TODO FIX ME!
        if (startCE == null || endCE == null) {
            return;
        }
        // There may be an End Date that is further out than than the End Date of the last item
        // with the latest Start Date
        if (startCE.getStartDate().compareTo(collectingEvent.getStartDate()) > 1) {
            startCE = collectingEvent;
        }
        Calendar leftCal = endCE.getEndDate() != null ? endCE.getEndDate() : endCE.getStartDate();
        Calendar rightCal = collectingEvent.getEndDate() != null ? collectingEvent.getEndDate()
                : collectingEvent.getStartDate();
        if (leftCal.compareTo(rightCal) < 0) {
            endCE = collectingEvent;
        }

        Hashtable<String, Object> map = new Hashtable<String, Object>();

        Set<CollectionObject> colObjs = collectingEvent.getCollectionObjects();

        map.put("startDate", collectingEvent.getStartDate());
        map.put("endDate", collectingEvent.getEndDate());

        Set<Object> taxonNames = new HashSet<Object>();
        for (CollectionObject co : colObjs) {
            for (Determination d : co.getDeterminations()) {
                if (d.isCurrentDet()) {
                    //System.out.println(d.getTaxon().getName() + "("+co.getCountAmt()+")");
                    Taxon taxon = d.getPreferredTaxon();
                    if (taxon != null) {
                        taxonNames.add(taxon.getName()
                                + (co.getCountAmt() != null ? " (" + co.getCountAmt() + ")" : ""));
                        if (taxon.getRankId() == 220) {
                            Taxon genus = taxon.getParent();
                            if (genus.getRankId() == 180) {
                                ImageGetter imgGetter = new ImageGetter(imageGetterList, imageMap, imageURLs,
                                        genus.getName(), taxon.getName());
                                imageGetterList.add(imgGetter);
                            }
                        }
                    }
                    break;
                }
            }
        }
        map.put("taxonItems", taxonNames);

        map.put("latitude1", locality.getLatitude1());
        map.put("longitude1", locality.getLongitude1());

        /*
        Calendar cal = collectingEvent.getStartDate();
        if (cal != null)
        {
          labels.add(scrDateFormat.format(cal.getTime()));
                
        } else if (collectingEvent.getVerbatimDate() != null)
        {
          labels.add(collectingEvent.getVerbatimDate());
                
        } else
        {
          labels.add(Integer.toString(collectingEvent.getCollectingEventId()));
                
        }
        */
        labels.add(Integer.toString(collectingEvents.size()));
        localities.add(locality);
        valueList.add(map);

    }

    // XXX Fix me shouldn't be hard coded here to make it work
    localityMapper.setMaxMapWidth(515);
    localityMapper.setMaxMapHeight(375);

    Color arrow = new Color(220, 220, 220);
    localityMapper.setArrowColor(arrow);
    localityMapper.setDotColor(Color.WHITE);
    localityMapper.setDotSize(4);
    localityMapper.setLabelColor(Color.RED);

    int inx = 0;
    for (Locality locality : localities) {
        localityMapper.addLocationAndLabel(locality, labels != null ? labels.get(inx) : null);
        inx++;
    }
    localityMapper.setCurrentLoc(localities.get(0));
    localityMapper.setCurrentLocColor(Color.RED);

    // XXX DEMO  (Hard Coded 'null' means everyone would have one which may not be true)
    // "null" ViewSet name means it should use the default
    ViewIFace view = AppContextMgr.getInstance().getView("LocalityMapper");

    // TODO WHERE's the ERROR checking !
    multiView = new MultiView(null, null, view, AltViewIFace.CreationMode.VIEW, MultiView.NO_OPTIONS);
    multiView.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(138, 128, 128)),
                    BorderFactory.createEmptyBorder(4, 4, 4, 4)));

    formViewObj = multiView.getCurrentViewAsFormViewObj();
    formViewObj.getUIComponent().setBackground(Color.WHITE);

    imageJList = formViewObj.getCompById("taxonItems");
    imageJList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                String nameStr = (String) imageJList.getSelectedValue();
                if (nameStr != null) {
                    int index = nameStr.indexOf(" (");
                    if (index > -1) {
                        nameStr = nameStr.substring(0, index);
                    }
                }

                //System.out.println("Getting["+name+"]");
                Image img = null;
                if (StringUtils.isNotEmpty(nameStr)) {
                    img = imageMap.get(nameStr); // might return null
                    ImageDisplay imgDisplay = formViewObj.getCompById("image");
                    if (img != null) {
                        imgDisplay.setImage(new ImageIcon(img));
                    } else {
                        imgDisplay.setImage((Image) null);
                    }
                }

            }
        }
    });

    // XXX TODO FIX ME!
    if (startCE == null || endCE == null) {
        return;
    }
    String startDateStr = scrDateFormat.format(startCE.getStartDate().getTime());
    String endDateStr = scrDateFormat
            .format((endCE.getEndDate() != null ? endCE.getEndDate() : endCE.getStartDate()).getTime());

    Formatter formatter = new Formatter();
    titleLabel.setText(formatter
            .format(getResourceString("LocalityMapperTitle"), new Object[] { startDateStr, endDateStr })
            .toString());

    Font font = titleLabel.getFont();
    titleLabel.setFont(new Font(font.getFontName(), Font.BOLD, font.getSize() + 2));

    recordSetController = new ResultSetController(null, false, false, false, null, collectingEvents.size(),
            true);
    recordSetController.addListener(this);
    recordSetController.getPanel().setBackground(Color.WHITE);

    controlPanel = new ControlBarPanel(getBackground());
    controlPanel.add(recordSetController.getPanel());
    controlPanel.setRecordSetController(recordSetController);
    controlPanel.setBackground(Color.WHITE);

    googleBtn = new JButton(IconManager.getIcon("GoogleEarth", IconManager.STD_ICON_SIZE));
    googleBtn.setMargin(new Insets(1, 1, 1, 1));
    googleBtn.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    googleBtn.setSize(new Dimension(18, 18));
    googleBtn.setPreferredSize(new Dimension(18, 18));
    googleBtn.setMaximumSize(new Dimension(18, 18));
    googleBtn.setFocusable(false);
    googleBtn.setBackground(Color.WHITE);

    controlPanel.addButtons(new JButton[] { googleBtn }, false);

    googleBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                UIRegistry.displayStatusBarText("Exporting Collecting Events in KML."); // XXX I18N
                kmlGen.setSpeciesToImageMapper(imageURLs);
                kmlGen.outputToFile(System.getProperty("user.home") + File.separator + "specify.kml");

            } catch (Exception ex) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LocalityMapperSubPane.class, ex);
                ex.printStackTrace();
            }
        }
    });

    addMouseMotionListener(new MouseMotionListener() {
        public void mouseDragged(MouseEvent e) {
            // nothing
        }

        public void mouseMoved(MouseEvent e) {
            checkMouseLocation(e.getPoint(), false);
        }
    });

    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            checkMouseLocation(e.getPoint(), true);
        }

    });

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            getLocalityMap();
        }
    });

}

From source file:net.schweerelos.parrot.ui.GraphViewComponent.java

@SuppressWarnings("serial")
private void setupRenderContext(final VisualizationViewer<NodeWrapper, NodeWrapper> vis) {
    vis.setRenderer(new ParrotGraphRenderer());
    vis.setPickSupport(new ParrotPickSupport(vis));

    RenderContext<NodeWrapper, NodeWrapper> renderContext = vis.getRenderContext();

    final PickedInfo<NodeWrapper> vertexPickInfo = vis.getPickedVertexState();
    final PickedState<NodeWrapper> edgePickInfo = vis.getPickedEdgeState();

    // hide all edge arrows except for those on outgoing edges of picked
    // nodes//from  ww  w .j  a  v a 2  s.  c  o  m
    renderContext.setEdgeArrowPredicate(new Predicate<Context<Graph<NodeWrapper, NodeWrapper>, NodeWrapper>>() {
        @Override
        public boolean evaluate(Context<Graph<NodeWrapper, NodeWrapper>, NodeWrapper> context) {
            NodeWrapper edge = context.element;
            NodeWrapper source = graph.getSource(edge);
            return vertexPickInfo.isPicked(source);
        }
    });

    // make edges straight lines to collapse parallel edges
    renderContext.setEdgeShapeTransformer(new EdgeShape.Line<NodeWrapper, NodeWrapper>());

    // hide text of all edges except for outgoing edges of picked nodes
    renderContext.setEdgeLabelTransformer(new Transformer<NodeWrapper, String>() {
        @Override
        public String transform(NodeWrapper edge) {
            NodeWrapper source = graph.getSource(edge);
            NodeWrapper destination = graph.getDest(edge);
            if (vertexPickInfo.isPicked(source) && !vertexPickInfo.isPicked(destination)) {
                return edge.toString();
            } else {
                return "";
            }
        }
    });
    renderContext.setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(COLOR_EDGE_LABEL) {
        @Override
        public <E> Component getEdgeLabelRendererComponent(JComponent vv, Object value, Font font,
                boolean isSelected, E edge) {
            Component component = super.getEdgeLabelRendererComponent(vv, value, font, isSelected, edge);
            component.setForeground(COLOR_EDGE_LABEL);
            return component;
        }

    });

    // start from VertexLabelAsShapeDemo

    // this class will provide both label drawing and vertex shapes
    VertexLabelAsShapeRenderer<NodeWrapper, NodeWrapper> vlasr = new VertexLabelAsShapeRenderer<NodeWrapper, NodeWrapper>(
            renderContext);
    renderContext.setVertexShapeTransformer(vlasr);

    vis.setForeground(COLOR_NODE_TEXT);

    // customize the render context

    renderContext.setVertexLabelTransformer(new ToStringLabeller<NodeWrapper>());

    renderContext.setVertexLabelRenderer(new DefaultVertexLabelRenderer(COLOR_NODE_PICKED_TEXT) {
        @Override
        public <V> Component getVertexLabelRendererComponent(JComponent vv, Object value, Font font,
                boolean isSelected, V vertexToRender) {
            Component component = super.getVertexLabelRendererComponent(vv, value, font, isSelected,
                    vertexToRender);
            if (component instanceof JLabel) {
                JLabel label = (JLabel) component;
                // add a little bit of padding around the text
                Border originalBorder = label.getBorder();
                label.setBorder(BorderFactory.createCompoundBorder(originalBorder,
                        BorderFactory.createEmptyBorder(3, 2, 4, 2)));
            }
            // now set the colour/font too
            if (vertexToRender instanceof NodeWrapper) {
                NodeWrapper vertex = (NodeWrapper) vertexToRender;
                if (vertexPickInfo.isPicked(vertex)) {
                    component.setForeground(COLOR_NODE_PICKED_TEXT);
                } else if (vertex.isHighlighted()) {
                    component.setForeground(COLOR_NODE_HIGHLIGHTED_TEXT);
                    component.setFont(font.deriveFont(Font.BOLD));
                } else if (GraphViewHelper.hasPickedNeighbour(vertex, vertexPickInfo, graph)) {
                    component.setForeground(COLOR_NODE_WITH_PICKED_NEIGHBOUR_TEXT);
                } else if (GraphViewHelper.hasPickedAdjacentEdge(vertex, edgePickInfo, graph)) {
                    component.setForeground(COLOR_NODE_ADJACENT_EDGE_PICKED_TEXT);
                } else if (GraphViewHelper.hasHighlightedNeighbour(vertex, graph)) {
                    component.setForeground(COLOR_NODE_WITH_HIGHLIGHTED_NEIGHBOUR_TEXT);
                } else {
                    component.setForeground(COLOR_NODE_TEXT);
                }
            }

            return component;
        }
    });

    // end from VertexLabelAsShapeDemo

    vis.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    vis.setVertexToolTipTransformer(new Transformer<NodeWrapper, String>() {
        @Override
        public String transform(NodeWrapper vertex) {
            return vertex.getToolTipText(model);
        }
    });

    // inspired by PluggableRendererDemo
    Transformer<NodeWrapper, Paint> vertexOutline = new Transformer<NodeWrapper, Paint>() {
        @Override
        public Paint transform(NodeWrapper vertex) {
            if (vertexPickInfo.isPicked(vertex)) {
                return COLOR_NODE_PICKED_BORDER;
            } else if (vertex.isHighlighted()) {
                return COLOR_NODE_HIGHLIGHTED_BORDER;
            } else {
                if (GraphViewHelper.hasPickedAdjacentEdge(vertex, edgePickInfo, graph)) {
                    return COLOR_NODE_ADJACENT_EDGE_PICKED_BORDER;
                }
                if (GraphViewHelper.hasPickedNeighbour(vertex, vertexPickInfo, graph)) {
                    return COLOR_NODE_WITH_PICKED_NEIGHBOUR_BORDER;
                } else if (GraphViewHelper.hasHighlightedNeighbour(vertex, graph)) {
                    return COLOR_NODE_WITH_HIGHLIGHTED_NEIGHBOUR_BORDER;
                }
                // will get here only if no neighbour is picked/highlighted
                return COLOR_NODE_BORDER;
            }
        }
    };
    renderContext.setVertexDrawPaintTransformer(vertexOutline);

    Transformer<NodeWrapper, Paint> vertexBackground = new Transformer<NodeWrapper, Paint>() {
        @Override
        public Paint transform(NodeWrapper vertex) {
            if (vertexPickInfo.isPicked(vertex)) {
                return COLOR_NODE_PICKED_BG;
            } else if (vertex.isHighlighted()) {
                return COLOR_NODE_HIGHLIGHTED_BG;
            } else {
                if (GraphViewHelper.hasPickedAdjacentEdge(vertex, edgePickInfo, graph)) {
                    return COLOR_NODE_ADJACENT_EDGE_PICKED_BG;
                }
                if (GraphViewHelper.hasPickedNeighbour(vertex, vertexPickInfo, graph)) {
                    return COLOR_NODE_WITH_PICKED_NEIGHBOUR_BG;
                } else if (GraphViewHelper.hasHighlightedNeighbour(vertex, graph)) {
                    return COLOR_NODE_WITH_HIGHLIGHTED_NEIGHBOUR_BG;
                }
                return COLOR_NODE_BG;
            }
        }
    };
    renderContext.setVertexFillPaintTransformer(vertexBackground);

    Transformer<NodeWrapper, Stroke> vertexStroke = new Transformer<NodeWrapper, Stroke>() {
        @Override
        public Stroke transform(NodeWrapper vertex) {
            if (vertexPickInfo.isPicked(vertex)) {
                return STROKE_VERTEX_PICKED;
            } else if (vertex.isHighlighted()) {
                return STROKE_VERTEX_HIGHLIGHTED;
            }

            Collection<NodeWrapper> edges = graph.getInEdges(vertex);
            for (NodeWrapper edge : edges) {
                if (edgePickInfo.isPicked(edge)) {
                    return STROKE_VERTEX_INCOMING_EDGE_PICKED;
                }
            }
            edges = graph.getOutEdges(vertex);
            for (NodeWrapper edge : edges) {
                if (edgePickInfo.isPicked(edge)) {
                    return STROKE_VERTEX_OUTGOING_EDGE_PICKED;
                }
            }

            // we'll only get here if none of the cases above applies
            return STROKE_VERTEX_DEFAULT;
        }
    };
    renderContext.setVertexStrokeTransformer(vertexStroke);

    Transformer<NodeWrapper, Stroke> edgeStroke = new Transformer<NodeWrapper, Stroke>() {
        @Override
        public Stroke transform(NodeWrapper edge) {
            NodeWrapper edgeSource = graph.getSource(edge);
            if (edgePickInfo.isPicked(edge)) {
                return STROKE_EDGE_PICKED;
            } else if (vertexPickInfo.isPicked(edgeSource)) {
                return STROKE_EDGE_ADJACENT_NODE_PICKED;
            } else {
                return STROKE_EDGE_DEFAULT;
            }
        }
    };
    renderContext.setEdgeStrokeTransformer(edgeStroke);

    Transformer<NodeWrapper, Paint> edgeColor = new Transformer<NodeWrapper, Paint>() {
        @Override
        public Paint transform(NodeWrapper edge) {
            if (edgePickInfo.isPicked(edge)) {
                return COLOR_EDGE_PICKED;
            } else if (GraphViewHelper.hasPickedAdjacentVertex(edge, vertexPickInfo, graph)) {
                return COLOR_EDGE_ADJACENT_VERTEX_PICKED;
            } else if (edge.isHighlighted()) {
                return COLOR_EDGE_HIGHLIGHTED;
            } else if (GraphViewHelper.hasHighlightedAdjacentVertex(edge, graph)) {
                return COLOR_EDGE_ADJACENT_VERTEX_HIGHLIGHTED;
            } else {
                return COLOR_EDGE;
            }
        }
    };
    renderContext.setEdgeDrawPaintTransformer(edgeColor);
    // draw arrows in the same colour as edges
    renderContext.setArrowDrawPaintTransformer(edgeColor);
    renderContext.setArrowFillPaintTransformer(edgeColor);

    includePredicate = new IncludePredicate<Context<Graph<NodeWrapper, NodeWrapper>, NodeWrapper>>();
    renderContext.setEdgeIncludePredicate(includePredicate);
    renderContext.setVertexIncludePredicate(includePredicate);

    vis.setBackground(COLOR_BACKGROUND);

    mouse = new DoubleClickPickingModalGraphMouse<NodeWrapper, NodeWrapper>();
    mouse.add(new AbstractPopupGraphMousePlugin() {
        @Override
        protected void handlePopup(MouseEvent e) {
            if (!e.isPopupTrigger()) {
                return;
            }
            GraphElementAccessor<NodeWrapper, NodeWrapper> pickSupport = vis.getPickSupport();
            if (pickSupport == null) {
                return;
            }

            NodeWrapper node = pickSupport.getVertex(layout, e.getX(), e.getY());
            if (node == null) {
                node = pickSupport.getEdge(layout, e.getX(), e.getY());
            }
            if (node == null) {
                return;
            }
            popup.setNodeWrapper(node);
            popup.show(vis, e.getX(), e.getY());
        }
    });
    mouse.setDoubleClickPickingPlugin(new DoubleClickPickingPlugin() {
        @Override
        void doubleClickOccurred(MouseEvent e) {
            GraphElementAccessor<NodeWrapper, NodeWrapper> pickSupport = vis.getPickSupport();
            if (pickSupport == null) {
                return;
            }

            NodeWrapper node = pickSupport.getVertex(layout, e.getX(), e.getY());
            if (node == null) {
                return;
            }
            fireNodeSelected(node);
        }
    });
    vis.setGraphMouse(mouse);

}

From source file:eu.delving.sip.Application.java

private JPanel createStatePanel() {
    statusPanel.setReaction(ABSENT, allFrames.prepareForNothing());
    statusPanel.setReaction(NO_DATA, importAction);
    statusPanel.setReaction(IMPORTED, new InputAnalyzer());
    statusPanel.setReaction(ANALYZED_IMPORT, allFrames.prepareForDelimiting());
    statusPanel.setReaction(DELIMITED, new ConvertPerformer());
    statusPanel.setReaction(SOURCED, new InputAnalyzer());
    statusPanel.setReaction(ANALYZED_SOURCE, allFrames.prepareForMapping(desktop));
    statusPanel.setReaction(MAPPING, validateAction);
    if (uploadAction == null) {
        statusPanel.setReaction(VALIDATED, allFrames.prepareForNothing());
    } else {//from  w w w. j av a 2 s  . c o m
        statusPanel.setReaction(VALIDATED, uploadAction);
    }
    JPanel p = new JPanel(new GridLayout(1, 0, 6, 6));
    p.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(0),
            BorderFactory.createEmptyBorder(6, 6, 6, 6)));
    p.add(statusPanel);
    JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.add(new WorkPanel(sipModel), BorderLayout.CENTER);
    rightPanel.add(createButtonPanel(), BorderLayout.WEST);
    p.add(rightPanel);
    return p;
}

From source file:edu.ku.brc.specify.utilapps.ERDTable.java

/**
 * @param font//from   w w  w .  j a  v a2s.  c om
 */
public void build(final Font font) {
    int numRows = 7;
    switch (displayType) {
    case All:
        numRows = 7;
        break;
    case MainFields:
        numRows = 7;
        break;
    case Title:
        numRows = 1;
        break;
    case TitleAndRel:
        numRows = 4;
        break;

    }
    Font bold = new Font(font.getFamily(), Font.BOLD, font.getSize());
    Font italic = new Font(font.getFamily(), Font.ITALIC, font.getSize());
    PanelBuilder pb = new PanelBuilder(
            new FormLayout("f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", numRows)));
    CellConstraints cc = new CellConstraints();

    String className = StringUtils.substringAfterLast(table.getClassName(), ".");
    DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByShortClassName(className);
    if (tblInfo == null) {
        throw new RuntimeException("Couldn't find table for className[" + className + "]");
    }
    String tblName = tblInfo.getTitle();
    int y = 1;
    pb.add(ERDVisualizer.mkLabel(bold, tblName, SwingConstants.CENTER), cc.xy(1, y));
    y += 2;

    boolean doingAll = displayType == DisplayType.All;
    if (displayType == DisplayType.All || displayType == DisplayType.MainFields) {
        pb.addSeparator("", cc.xy(1, y));
        y += 2;

        pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELDS"), SwingConstants.CENTER),
                cc.xy(1, y));
        y += 2;

        String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px,p:g,4px" : "") + ",f:p:g";
        PanelBuilder fieldsPB = new PanelBuilder(new FormLayout(colsDef,
                UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getFields().size() + 2)));
        int yy = 1;

        fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELD"), SwingConstants.LEFT),
                cc.xy(1, yy));
        fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER),
                cc.xy(3, yy));
        fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_LENGTH"), SwingConstants.CENTER),
                cc.xy(5, yy));
        if (doingAll) {
            fieldsPB.add(
                    ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER),
                    cc.xy(7, yy));
            fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_UNIQUE"), SwingConstants.CENTER),
                    cc.xy(9, yy));
        }
        yy += 2;

        if (StringUtils.isNotEmpty(table.getIdColumnName())) {
            build(fieldsPB, table, font, yy, doingAll); // does ID
            yy += 2;
        }

        for (DBFieldInfo f : table.getFields()) {
            build(fieldsPB, f, font, yy, doingAll);
            yy += 2;
        }
        pb.add(fieldsPB.getPanel(), cc.xy(1, y));
        y += 2;

    }

    if ((displayType == DisplayType.All || displayType == DisplayType.TitleAndRel)
            && table.getRelationships().size() > 0) {
        pb.addSeparator("", cc.xy(1, y));
        y += 2;

        pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_RELATIONSHIPS"), SwingConstants.CENTER),
                cc.xy(1, y));
        y += 2;

        String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px" : "") + ",f:p:g";
        PanelBuilder relsPB = new PanelBuilder(new FormLayout(colsDef,
                UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getRelationships().size() + 1)));
        int yy = 1;

        relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TABLE"), SwingConstants.LEFT),
                cc.xy(1, yy));
        relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_NAME"), SwingConstants.CENTER),
                cc.xy(3, yy));
        relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER),
                cc.xy(5, yy));
        if (doingAll) {
            relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER),
                    cc.xy(7, yy));
        }
        yy += 2;

        Vector<DBRelationshipInfo> orderedList = new Vector<DBRelationshipInfo>(table.getRelationships());
        Collections.sort(orderedList, new Comparator<DBRelationshipInfo>() {
            public int compare(DBRelationshipInfo o1, DBRelationshipInfo o2) {
                String name1 = ((DBRelationshipInfo) o1).getClassName();
                if (name1.startsWith("Sp")) {
                    name1 = name1.substring(2, name1.length());
                }
                String name2 = ((DBRelationshipInfo) o2).getClassName();
                if (name2.startsWith("Sp")) {
                    name2 = name2.substring(2, name2.length());
                }
                return name1.compareTo(name2);
            }
        });

        for (DBRelationshipInfo r : orderedList) {
            //System.out.println(r.getName()+" "+r.getType());
            if (!r.getName().toLowerCase().endsWith("iface")) {
                JComponent p = build(relsPB, r, font, yy, doingAll);
                relUIHash.put(r, p);
                yy += 2;
            }
        }
        pb.add(relsPB.getPanel(), cc.xy(1, y));
        y += 2;

        //fieldsPB.getPanel().setBackground(Color.GREEN);
        //relsPB.getPanel().setBackground(Color.BLUE);
    }

    inner = pb.getPanel();
    //inner.setBorder(BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP));

    inner.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK),
            BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP)));

    setBackground(Color.WHITE);
    add(inner, BorderLayout.CENTER);
}

From source file:ecg.ecgshow.ECGShowUI.java

private void createPressureData(long timeZone) {
    PressureData = new JPanel();
    PressuredateAxises = new DateAxis[1];
    SystolicPressureSeries = new TimeSeries[2];
    DiastolicPressureSeries = new TimeSeries[2];

    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    SystolicPressureSeries[0] = new TimeSeries("");
    SystolicPressureSeries[0].setMaximumItemAge(timeZone);
    SystolicPressureSeries[0].setMaximumItemCount(500);
    SystolicPressureSeries[1] = new TimeSeries("");
    SystolicPressureSeries[1].setMaximumItemAge(timeZone);
    SystolicPressureSeries[1].setMaximumItemCount(2);
    timeseriescollection.addSeries(SystolicPressureSeries[0]);
    timeseriescollection.addSeries(SystolicPressureSeries[1]);

    PressuredateAxises[0] = new DateAxis("");
    PressuredateAxises[0].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
    PressuredateAxises[0].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
    PressuredateAxises[0].setTickLabelsVisible(true);
    PressuredateAxises[0].setVisible(false);

    DiastolicPressureSeries[0] = new TimeSeries("");
    DiastolicPressureSeries[0].setMaximumItemAge(timeZone);
    DiastolicPressureSeries[0].setMaximumItemCount(500);
    DiastolicPressureSeries[1] = new TimeSeries("");
    DiastolicPressureSeries[1].setMaximumItemAge(timeZone);
    DiastolicPressureSeries[1].setMaximumItemCount(2);
    timeseriescollection.addSeries(DiastolicPressureSeries[0]);
    timeseriescollection.addSeries(DiastolicPressureSeries[1]);

    NumberAxis numberaxis = new NumberAxis("Pressure");
    numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
    numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setVisible(false);//  www  .  j a  v a  2s.c o m
    numberaxis.setLowerBound(0D);
    numberaxis.setUpperBound(200D);

    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); //
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); //
    xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); //
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5));

    xylineandshaperenderer.setSeriesPaint(2, Color.ORANGE); //
    xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2)); //
    xylineandshaperenderer.setSeriesPaint(3, Color.LIGHT_GRAY); //
    xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(5));

    //XYPlot xyplot = new XYPlot(timeseriescollection, PressuredateAxises[0], numberaxis, xylineandshaperenderer);
    XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[0], numberaxis, xylineandshaperenderer);

    xyplot.setBackgroundPaint(Color.LIGHT_GRAY);
    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setBackgroundPaint(Color.BLACK);

    JFreeChart jfreechart = new JFreeChart(xyplot);
    jfreechart.setBackgroundPaint(new Color(237, 237, 237));//?
    jfreechart.getLegend().setVisible(false);

    ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 0.155), (int) (HEIGHT * 0.18), 0, 0,
            Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false);

    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0
            , BorderFactory.createEmptyBorder() //????
    ));
    chartpanel.setMouseZoomable(false);
    PressureData.add(chartpanel);

}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java

/**
 * Creates a panel containing a text field used to search
 * @return/*  w w w  .  ja  va  2s  . c o  m*/
 */
private JPanel createSearchStringPanel() {

    JPanel searchStringPanel = new JPanel();
    searchStringPanel.setLayout(new BorderLayout());
    searchStringPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
                    Localizer.get("DialogIMDB.panel-search-string.title")), //$NON-NLS-1$
            BorderFactory.createEmptyBorder(4, 4, 4, 4)));

    searchStringField = new JTextField(27);
    searchStringField.setActionCommand("Search String:"); //$NON-NLS-1$
    searchStringField.setCaretPosition(0);
    searchStringField.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                executeSearch();
            }
        }
    });

    searchStringPanel.add(searchStringField, BorderLayout.NORTH);

    return searchStringPanel;
}

From source file:CGgui.java

public CGgui() {
    //main window frame
    f.setResizable(false);/*from   www.j  a v  a 2  s  . c om*/
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(fCenter, BorderLayout.CENTER);
    f.getContentPane().add(fEast, BorderLayout.EAST);

    //menu
    mnuFile.add(mnuLoad);
    mnuLoad.add(mnuItemOpenFasta);
    mnuLoad.add(mnuItemOpenBed);
    mnuFile.add(mnuSaveData);
    mnuSaveData.add(mnuItemSavePositions);
    mnuSaveData.add(mnuItemSaveClusters);

    //mnuFile.add(mnuItemOpenDataFile);
    mnuFile.add(mnuSaveCharts);
    mnuSaveCharts.add(mnuItemSaveChrt);
    mnuSaveCharts.add(mnuItemSaveMinChrt);
    mnuSaveCharts.add(mnuItemSaveClusterChrt);
    mnuSaveCharts.add(mnuItemSaveGrayChrt);
    mnuSaveCharts.add(mnuItemSaveGrayMinChrt);
    mnuSaveCharts.add(mnuItemSaveGrayClusterChrt);
    mnuFile.add(mnuItemClearData);
    mnuFile.add(mnuItemQuit);
    mnuEdit.add(mnuItemChartProps);
    mnuEdit.add(mnuItemMinimaProps);
    mnuEdit.add(mnuItemClusterProps);
    mnuEdit.add(mnuItemFindMin);
    mnuEdit.add(mnuItemSetAxes);
    mnuEdit.add(mnuItemShowGrid);
    //   mnuHelp.add(mnuItemMan);
    //   mnuHelp.add(mnuItemAbout);
    mb.add(mnuFile);
    mb.add(mnuEdit);
    //   mb.add(mnuHelp);
    f.setJMenuBar(mb);

    //progressbar
    jprogressbar.setVisible(false);
    jprogressbar.setBorderPainted(false);
    f.getContentPane().add(jprogressbar, BorderLayout.SOUTH);

    //chart area
    //histogram
    ChartArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    chart = ChartFactory.createXYAreaChart("Fragment Length Histogram", "Fragment Length (l)", "Frequency f(l)",
            histogramdataset, PlotOrientation.VERTICAL, true, true, false);
    chart.addSubtitle(0, new TextTitle("n = " + CurrCG));
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setForegroundAlpha(0.85F);
    xyplot.setDomainCrosshairVisible(false);
    chartpanel = new ChartPanel(chart);
    ChartArea.add("Fragment Length", chartpanel);

    //minima
    minchart = ChartFactory.createXYLineChart("Local Minima", "Fragment Length (l)",
            "Number of Matches per Fragment", minimadataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot minxyplot = (XYPlot) minchart.getPlot();
    minxyplot.setForegroundAlpha(0.85F);
    minchartpanel = new ChartPanel(minchart);
    ChartArea.add("Minima", minchartpanel);

    //optimization
    clusterchart = ChartFactory.createScatterPlot("Average Cluster Size vs. Maximum Fragment Length",
            "Number (n) of Matches per Fragment",
            "Number of Overlapping Fragments per Cluster/Max Fragment Length", clusterdataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot clusterplot = (XYPlot) clusterchart.getPlot();
    clusterplot.setForegroundAlpha(0.85F);
    clusterchartpanel = new ChartPanel(clusterchart);
    ChartArea.add("Optimization", clusterchartpanel);

    //text area
    SeqText.setLineWrap(true);
    SeqText.setWrapStyleWord(true);
    SeqText.setEditable(false);
    jScrollPane.setBorder(BorderFactory
            .createCompoundBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Debug"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)), jScrollPane.getBorder()));
    textPanel.add(jScrollPane);
    //this next line is a hack to fix the ScrollPane size when the chart is scrolled
    jScrollPane.setPreferredSize(jScrollPane.getPreferredSize());
    //auto scroll to added text
    SeqText.setAutoscrolls(true);
    jScrollPane.setAutoscrolls(true);

    //center panel layout
    GroupLayout centerlayout = new GroupLayout(fCenter);
    fCenter.setLayout(centerlayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h1 = centerlayout.createSequentialGroup();
    SequentialGroup v1 = centerlayout.createSequentialGroup();
    ////grouping
    h1.addGroup(centerlayout.createParallelGroup().addComponent(ChartArea).addComponent(textPanel));
    centerlayout.setHorizontalGroup(h1);
    ////more grouping
    v1.addGroup(centerlayout.createParallelGroup().addComponent(ChartArea));
    v1.addGroup(centerlayout.createParallelGroup().addComponent(textPanel));
    centerlayout.setVerticalGroup(v1);

    //CG Panel (search settings panel)
    CGPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Search Settings"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            CGPanel.getBorder()));
    //set subpanel1 layout
    GroupLayout CGsublayout1 = new GroupLayout(CGsubPanel1);
    CGsubPanel1.setLayout(CGsublayout1);
    ////Create a sequential and a parallel groups
    SequentialGroup h4 = CGsublayout1.createSequentialGroup();
    SequentialGroup v4 = CGsublayout1.createSequentialGroup();
    ////grouping
    h4.addGroup(CGsublayout1.createParallelGroup().addComponent(searchPatternLabel).addComponent(minCGsLabel)
            .addComponent(maxCGsLabel).addComponent(CGstepLabel).addComponent(smoothCheckBox)
            .addComponent(CGApplyButton).addComponent(CGsetCurrLabel));
    h4.addGroup(CGsublayout1.createParallelGroup().addComponent(searchPatternText).addComponent(minCGsText)
            .addComponent(maxCGsText).addComponent(CGstepText).addComponent(smoothText)
            .addComponent(CGResetButton).addComponent(CGcurrText));
    CGsublayout1.setHorizontalGroup(h4);
    ////more grouping
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(searchPatternLabel).addComponent(searchPatternText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(minCGsLabel)
            .addComponent(minCGsText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxCGsLabel)
            .addComponent(maxCGsText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGstepLabel)
            .addComponent(CGstepText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(smoothCheckBox)
            .addComponent(smoothText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGApplyButton)
            .addComponent(CGResetButton));
    v4.addContainerGap(15, 15);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGsetCurrLabel)
            .addComponent(CGcurrText));
    CGsublayout1.setVerticalGroup(v4);

    //set subpanel2 layout
    GroupLayout CGsublayout2 = new GroupLayout(CGsubPanel2);
    CGsubPanel2.setLayout(CGsublayout2);
    ////Create a sequential and a parallel groups
    SequentialGroup hSettingsSub2 = CGsublayout2.createSequentialGroup();
    SequentialGroup vSettingsSub2 = CGsublayout2.createSequentialGroup();

    ////horizontal grouping
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGsetCurrLabel));
    hSettingsSub2.addContainerGap(25, 25);
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGcurrText));
    hSettingsSub2.addContainerGap(25, 25);
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGsetCurrButton));
    CGsublayout2.setHorizontalGroup(hSettingsSub2);
    ////vertical grouping
    vSettingsSub2.addGroup(CGsublayout2.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(CGsetCurrLabel).addComponent(CGcurrText).addComponent(CGsetCurrButton));
    CGsublayout2.setVerticalGroup(vSettingsSub2);

    //set overall layout (subpanel3)
    GroupLayout CGsublayout3 = new GroupLayout(CGsubPanel3);
    CGsubPanel3.setLayout(CGsublayout3);
    ////Create a sequential and a parallel groups
    SequentialGroup h5 = CGsublayout3.createSequentialGroup();
    SequentialGroup v5 = CGsublayout3.createSequentialGroup();
    ////grouping
    h5.addGroup(CGsublayout3.createParallelGroup().addComponent(caseCheckBox).addComponent(CGsubPanel1)
            .addComponent(CGsubPanel2));
    CGsublayout3.setHorizontalGroup(h5);
    ////more grouping
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(caseCheckBox));
    v5.addContainerGap(5, 5);
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(CGsubPanel1));
    v5.addContainerGap(5, 5);
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(CGsubPanel2));
    CGsublayout3.setVerticalGroup(v5);
    //add to resizable container
    CGPanel.add(CGsubPanel3);
    //button and slider listeners
    CGApplyButton.addActionListener(new ListenCGApplyButton());
    CGResetButton.addActionListener(new ListenCGResetButton());
    CGsetCurrButton.addActionListener(new ListenCGsetCurrButton());
    CGcurrText.addActionListener(new ListenCGsetCurrButton());

    //minimum area
    findminPanel.setVisible(true);
    findminPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Find Minimum"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            findminPanel.getBorder()));
    GroupLayout minlayout = new GroupLayout(findminPanel);
    findminPanel.setLayout(minlayout);

    ////Create a sequential and a parallel groups
    SequentialGroup h2 = minlayout.createSequentialGroup();
    SequentialGroup v2 = minlayout.createSequentialGroup();

    ////group find minimum and find all buttons
    SequentialGroup hFindMinButtons = minlayout.createSequentialGroup();
    SequentialGroup vFindMinButtons = minlayout.createSequentialGroup();
    hFindMinButtons.addGroup(minlayout.createParallelGroup().addComponent(CalcButton));
    hFindMinButtons.addGroup(minlayout.createParallelGroup().addComponent(CalcAllButton));
    vFindMinButtons.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(CalcButton).addComponent(CalcAllButton));
    ////general grouping
    h2.addGroup(minlayout.createParallelGroup().addComponent(minLabel).addComponent(maxLabel)
            .addComponent(ClearButton));
    h2.addContainerGap(5, 5);
    h2.addGroup(minlayout.createParallelGroup().addComponent(minText).addComponent(maxText)
            .addGroup(hFindMinButtons));
    h2.addContainerGap(5, 5);
    h2.addGroup(minlayout.createParallelGroup().addComponent(minGrabButton).addComponent(maxGrabButton)
            .addComponent(CancelButton));
    minlayout.setHorizontalGroup(h2);
    ////more grouping
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(minLabel)
            .addComponent(minText).addComponent(minGrabButton));
    v2.addContainerGap(5, 5);
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxLabel)
            .addComponent(maxText).addComponent(maxGrabButton));
    v2.addContainerGap(5, 5);
    v2.addContainerGap(5, 5);
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(ClearButton)
            .addGroup(vFindMinButtons).addComponent(CancelButton));
    minlayout.setVerticalGroup(v2);
    //add button listeners
    ClearButton.addActionListener(new ListenClearButton());
    CalcButton.addActionListener(new ListenCalcButton());
    CalcAllButton.addActionListener(new ListenCalcAllButton());
    CancelButton.addActionListener(new ListenCancelButton());
    minGrabButton.addActionListener(new ListenminGrabButton());
    maxGrabButton.addActionListener(new ListenmaxGrabButton());

    //axes panel
    mnuItemSetAxes.setState(false);
    setaxesPanel.setVisible(false);
    setaxesPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Set Domain"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            setaxesPanel.getBorder()));
    GroupLayout setaxeslayout = new GroupLayout(setaxesPanel);
    setaxesPanel.setLayout(setaxeslayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h6 = setaxeslayout.createSequentialGroup();
    SequentialGroup v6 = setaxeslayout.createSequentialGroup();
    ////grouping
    h6.addGroup(setaxeslayout.createParallelGroup().addComponent(mindomainLabel).addComponent(maxdomainLabel)
            .addComponent(SetDomainButton));
    h6.addContainerGap(5, 5);
    h6.addGroup(setaxeslayout.createParallelGroup().addComponent(mindomainText).addComponent(maxdomainText)
            .addComponent(ResetDomainButton));
    setaxeslayout.setHorizontalGroup(h6);
    ////more grouping
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(mindomainLabel)
            .addComponent(mindomainText));
    v6.addContainerGap(5, 5);
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxdomainLabel)
            .addComponent(maxdomainText));
    v6.addContainerGap(5, 5);
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(SetDomainButton)
            .addComponent(ResetDomainButton));
    setaxeslayout.setVerticalGroup(v6);
    //add button listeners
    SetDomainButton.addActionListener(new ListenSetDomainButton());
    ResetDomainButton.addActionListener(new ListenResetDomainButton());

    //east panel layout
    GroupLayout eastlayout = new GroupLayout(fEast);
    fEast.setLayout(eastlayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h3 = eastlayout.createSequentialGroup();
    SequentialGroup v3 = eastlayout.createSequentialGroup();
    ////grouping
    h3.addGroup(eastlayout.createParallelGroup().addComponent(CGPanel).addComponent(findminPanel)
            .addComponent(setaxesPanel));
    eastlayout.setHorizontalGroup(h3);
    ////more grouping
    v3.addGroup(eastlayout.createParallelGroup().addComponent(CGPanel));
    v3.addGroup(eastlayout.createParallelGroup().addComponent(findminPanel));
    v3.addGroup(eastlayout.createParallelGroup().addComponent(setaxesPanel));
    eastlayout.setVerticalGroup(v3);

    //listen for exit signals
    f.addWindowListener(new ListenCloseWdw());
    mnuItemQuit.addActionListener(new ListenMenuQuit());

    //listen for exit signals
    f.addWindowListener(new ListenCloseWdw());
    mnuItemClearData.addActionListener(new ListenClearData());

    //listen for open signal
    mnuItemOpenFasta.addActionListener(new ListenMenuOpenFasta());

    //listen for open signal
    mnuItemOpenBed.addActionListener(new ListenMenuOpenBed());

    //listen for save position signal
    mnuItemSavePositions.addActionListener(new ListenMenuSavePositions());

    //listen for save cluster signal
    mnuItemSaveClusters.addActionListener(new ListenMenuSaveClusters());

    //listen for save histogram chart signal
    mnuItemSaveChrt.addActionListener(new ListenMenuSaveChrt());

    //listen for save chart signal
    mnuItemSaveMinChrt.addActionListener(new ListenMenuSaveMinChrt());

    //listen for save cluster chart signal
    mnuItemSaveClusterChrt.addActionListener(new ListenMenuSaveClusterChrt());

    //listen for save histogram chart in grayscale signal;
    mnuItemSaveGrayChrt.addActionListener(new ListenMenuSaveGrayChrt());

    //listen for save chart signal
    mnuItemSaveGrayMinChrt.addActionListener(new ListenMenuSaveGrayMinChrt());

    //listen for save cluster chart signal
    mnuItemSaveGrayClusterChrt.addActionListener(new ListenMenuSaveGrayClusterChrt());

    //listen for edit histogram properties signal
    mnuItemChartProps.addActionListener(new ListenMenuChartProps());

    //listen for edit minima chart properties signal
    mnuItemMinimaProps.addActionListener(new ListenMenuMinimaProps());

    //listen for edit optimization chart properties signal
    mnuItemClusterProps.addActionListener(new ListenMenuClusterProps());

    //listen for find minimum signal
    mnuItemFindMin.addActionListener(new ListenMenuFindMin());

    //listen for find minimum signal
    mnuItemSetAxes.addActionListener(new ListenMenuSetAxes());

    //listen for show gridlines
    mnuItemShowGrid.addActionListener(new ListenMenuShowGrid());

    //other menu items

    //garbage collect
    //System.gc();
}

From source file:projects.wdlf47tuc.ProcessAllSwathcal.java

/**
 * Main entry point./*from  w w  w  . j  a va 2s.c  o m*/
 * 
 * @param args
 * 
 * @throws IOException 
 * 
 */
public ProcessAllSwathcal() {

    // Path to AllSwathcal.dat file
    File allSwathcal = new File(
            "/home/nrowell/Astronomy/Data/47_Tuc/Kalirai_2012/UVIS/www.stsci.edu/~jkalirai/47Tuc/AllSwathcal.dat");

    // Read file contents into the List
    try (BufferedReader in = new BufferedReader(new FileReader(allSwathcal))) {
        String sourceStr;
        while ((sourceStr = in.readLine()) != null) {
            Source source = Source.parseSource(sourceStr);
            if (source != null) {
                allSources.add(source);
            }
        }
    } catch (IOException e) {
    }

    logger.info("Parsed " + allSources.size() + " Sources from AllSwathcal.dat");

    // Initialise chart
    cmdPanel = new ChartPanel(updateDataAndPlotCmd(allSources));
    cmdPanel.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent e) {
            // Capture mouse click location, transform to graph coordinates and add
            // a point to the polygonal selection box.
            Point2D p = cmdPanel.translateScreenToJava2D(e.getTrigger().getPoint());
            Rectangle2D plotArea = cmdPanel.getScreenDataArea();
            XYPlot plot = (XYPlot) cmdPanel.getChart().getPlot();
            double chartX = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
            double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge());
            points.add(new double[] { chartX, chartY });
            cmdPanel.setChart(plotCmd());
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent arg0) {
        }
    });

    // Create colour combo boxes
    final JComboBox<Filter> magComboBox = new JComboBox<Filter>(filters);
    final JComboBox<Filter> col1ComboBox = new JComboBox<Filter>(filters);
    final JComboBox<Filter> col2ComboBox = new JComboBox<Filter>(filters);

    // Set initial values
    magComboBox.setSelectedItem(magFilter);
    col1ComboBox.setSelectedItem(col1Filter);
    col2ComboBox.setSelectedItem(col2Filter);

    // Create an action listener for these
    ActionListener al = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            if (evt.getSource() == magComboBox) {
                magFilter = (Filter) magComboBox.getSelectedItem();
            }
            if (evt.getSource() == col1ComboBox) {
                col1Filter = (Filter) col1ComboBox.getSelectedItem();
            }
            if (evt.getSource() == col2ComboBox) {
                col2Filter = (Filter) col2ComboBox.getSelectedItem();
            }
            // Changed colour(s), so reset selection box coordinates
            points.clear();
            cmdPanel.setChart(updateDataAndPlotCmd(allSources));
        }
    };
    magComboBox.addActionListener(al);
    col1ComboBox.addActionListener(al);
    col2ComboBox.addActionListener(al);
    // Add a bit of padding to space things out
    magComboBox.setBorder(new EmptyBorder(5, 5, 5, 5));
    col1ComboBox.setBorder(new EmptyBorder(5, 5, 5, 5));
    col2ComboBox.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Set up statistic sliders
    final JSlider magErrMaxSlider = GuiUtil.buildSlider(magErrorRangeMin, magErrorRangeMax, 3, "%3.3f");
    final JSlider chi2MaxSlider = GuiUtil.buildSlider(chi2RangeMin, chi2RangeMax, 3, "%3.3f");
    final JSlider sharpMinSlider = GuiUtil.buildSlider(sharpRangeMin, sharpRangeMax, 3, "%3.3f");
    final JSlider sharpMaxSlider = GuiUtil.buildSlider(sharpRangeMin, sharpRangeMax, 3, "%3.3f");

    // Set intial values
    magErrMaxSlider.setValue(
            (int) Math.rint(100.0 * (magErrMax - magErrorRangeMin) / (magErrorRangeMax - magErrorRangeMin)));
    chi2MaxSlider.setValue((int) Math.rint(100.0 * (chi2Max - chi2RangeMin) / (chi2RangeMax - chi2RangeMin)));
    sharpMinSlider
            .setValue((int) Math.rint(100.0 * (sharpMin - sharpRangeMin) / (sharpRangeMax - sharpRangeMin)));
    sharpMaxSlider
            .setValue((int) Math.rint(100.0 * (sharpMax - sharpRangeMin) / (sharpRangeMax - sharpRangeMin)));

    // Set labels & initial values
    final JLabel magErrMaxLabel = new JLabel(getMagErrMaxLabel());
    final JLabel chi2MaxLabel = new JLabel(getChi2MaxLabel());
    final JLabel sharpMinLabel = new JLabel(getSharpMinLabel());
    final JLabel sharpMaxLabel = new JLabel(getSharpMaxLabel());

    // Create a change listener fot these
    ChangeListener cl = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();

            if (source == magErrMaxSlider) {
                // Compute max mag error from slider position
                double newMagErrMax = magErrorRangeMin
                        + (magErrorRangeMax - magErrorRangeMin) * (source.getValue() / 100.0);
                magErrMax = newMagErrMax;
                magErrMaxLabel.setText(getMagErrMaxLabel());
            }
            if (source == chi2MaxSlider) {
                // Compute Chi2 max from slider position
                double newChi2Max = chi2RangeMin + (chi2RangeMax - chi2RangeMin) * (source.getValue() / 100.0);
                chi2Max = newChi2Max;
                chi2MaxLabel.setText(getChi2MaxLabel());
            }
            if (source == sharpMinSlider) {
                // Compute sharp min from slider position
                double newSharpMin = sharpRangeMin
                        + (sharpRangeMax - sharpRangeMin) * (source.getValue() / 100.0);
                sharpMin = newSharpMin;
                sharpMinLabel.setText(getSharpMinLabel());
            }
            if (source == sharpMaxSlider) {
                // Compute sharp max from slider position
                double newSharpMax = sharpRangeMin
                        + (sharpRangeMax - sharpRangeMin) * (source.getValue() / 100.0);
                sharpMax = newSharpMax;
                sharpMaxLabel.setText(getSharpMaxLabel());
            }
            cmdPanel.setChart(updateDataAndPlotCmd(allSources));
        }
    };
    magErrMaxSlider.addChangeListener(cl);
    chi2MaxSlider.addChangeListener(cl);
    sharpMinSlider.addChangeListener(cl);
    sharpMaxSlider.addChangeListener(cl);
    // Add a bit of padding to space things out
    magErrMaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5));
    chi2MaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5));
    sharpMinSlider.setBorder(new EmptyBorder(5, 5, 5, 5));
    sharpMaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Text field to store distance modulus
    final JTextField distanceModulusField = new JTextField(Double.toString(mu));
    distanceModulusField.setBorder(new EmptyBorder(5, 5, 5, 5));

    Border compound = BorderFactory.createCompoundBorder(new LineBorder(this.getBackground(), 5),
            BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

    final JButton lfButton = new JButton("Luminosity function for selection");
    lfButton.setBorder(compound);
    lfButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            // Read distance modulus field
            try {
                double mu_new = Double.parseDouble(distanceModulusField.getText());
                mu = mu_new;
            } catch (NullPointerException | NumberFormatException ex) {
                JOptionPane.showMessageDialog(lfButton,
                        "Error parsing the distance modulus: " + ex.getMessage(), "Distance Modulus Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }

            if (boxedSources.isEmpty()) {
                JOptionPane.showMessageDialog(lfButton, "No sources are currently selected!", "Selection Error",
                        JOptionPane.ERROR_MESSAGE);
            } else {
                computeAndPlotLuminosityFunction(boxedSources);
            }
        }
    });
    final JButton clearSelectionButton = new JButton("Clear selection");
    clearSelectionButton.setBorder(compound);
    clearSelectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            points.clear();
            cmdPanel.setChart(plotCmd());
        }
    });

    JPanel controls = new JPanel(new GridLayout(9, 2));
    controls.setBorder(new EmptyBorder(10, 10, 10, 10));
    controls.add(new JLabel("Magnitude = "));
    controls.add(magComboBox);
    controls.add(new JLabel("Colour 1 = "));
    controls.add(col1ComboBox);
    controls.add(new JLabel("Colour 2 = "));
    controls.add(col2ComboBox);
    controls.add(magErrMaxLabel);
    controls.add(magErrMaxSlider);
    controls.add(chi2MaxLabel);
    controls.add(chi2MaxSlider);
    controls.add(sharpMinLabel);
    controls.add(sharpMinSlider);
    controls.add(sharpMaxLabel);
    controls.add(sharpMaxSlider);
    controls.add(new JLabel("Adopted distance modulus = "));
    controls.add(distanceModulusField);
    controls.add(lfButton);
    controls.add(clearSelectionButton);

    this.setLayout(new BorderLayout());
    this.add(cmdPanel, BorderLayout.CENTER);
    this.add(controls, BorderLayout.SOUTH);

    this.validate();
}

From source file:net.pms.newgui.LanguageSelection.java

private JComponent buildComponent() {
    // UIManager manages to get the background color wrong for text
    // components on OS X, so we apply the color manually
    Color backgroundColor = UIManager.getColor("Panel.background");
    rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.PAGE_AXIS));

    // It needs to be something in the title text, or the size calculation for the border will be wrong.
    selectionPanelBorder.setTitle(" ");
    selectionPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5),
            BorderFactory.createCompoundBorder(selectionPanelBorder,
                    BorderFactory.createEmptyBorder(10, 5, 10, 5))));
    selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.PAGE_AXIS));
    descriptionText.setEditable(false);/*  w  w w .  j  a  va  2 s.co m*/
    descriptionText.setBackground(backgroundColor);
    descriptionText.setFocusable(false);
    descriptionText.setLineWrap(true);
    descriptionText.setWrapStyleWord(true);
    descriptionText.setBorder(BorderFactory.createEmptyBorder(5, 15, 10, 15));
    selectionPanel.add(descriptionText);

    jLanguage = new JComboBox<>(keyedModel);
    jLanguage.setEditable(false);
    jLanguage.setPreferredSize(new Dimension(50, jLanguage.getPreferredSize().height));
    jLanguage.addActionListener(new LanguageComboBoxActionListener());
    languagePanel.setLayout(new BoxLayout(languagePanel, BoxLayout.PAGE_AXIS));
    languagePanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
    languagePanel.add(jLanguage);
    selectionPanel.add(languagePanel);

    warningText.setEditable(false);
    warningText.setFocusable(false);
    warningText.setBackground(backgroundColor);
    warningText.setFont(warningText.getFont().deriveFont(Font.BOLD));
    warningText.setLineWrap(true);
    warningText.setWrapStyleWord(true);
    warningText.setBorder(BorderFactory.createEmptyBorder(5, 15, 0, 15));
    selectionPanel.add(warningText);

    // It needs to be something in the title text, or the size calculation for the border will be wrong.
    infoTextBorder.setTitle(" ");
    infoText.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory
                    .createCompoundBorder(infoTextBorder, BorderFactory.createEmptyBorder(15, 20, 20, 20))));
    infoText.setEditable(false);
    infoText.setFocusable(false);
    infoText.setBackground(backgroundColor);
    infoText.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

    // This exercise is to avoid using the default shared StyleSheet with padding
    CustomHTMLEditorKit editorKit = new CustomHTMLEditorKit();
    StyleSheet styleSheet = new StyleSheet();
    styleSheet.addRule("a { color: #0000EE; text-decoration:underline; }");
    editorKit.setStyleSheet(styleSheet);
    infoText.setEditorKit(editorKit);
    infoText.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                boolean error = false;
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI(e.getDescription()));
                    } catch (IOException | URISyntaxException ex) {
                        LOGGER.error("Language selection failed to open translation page hyperlink: ",
                                ex.getMessage());
                        LOGGER.trace("", ex);
                        error = true;
                    }
                } else {
                    LOGGER.warn("Desktop is not supported, the clicked translation page link can't be opened");
                    error = true;
                }
                if (error) {
                    JOptionPane.showOptionDialog(dialog,
                            String.format(buildString("LanguageSelection.6", true), PMS.CROWDIN_LINK),
                            buildString("Dialog.Error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
                            null, null, null);
                }
            }
        }

    });

    rootPanel.add(selectionPanel);
    rootPanel.add(infoText);

    applyButton.addActionListener(new ApplyButtonActionListener());
    applyButton.setActionCommand("apply");

    selectButton.addActionListener(new SelectButtonActionListener());
    selectButton.setActionCommand("select");

    return rootPanel;

}