private void updateWindow(GraphElementAbstract element) { p.removeAll(); // this.element = element; // this.ab = (GraphElementAbstract) graphInstance // .getPathwayElement(element); original = element; PropertyWindowListener pwl = new PropertyWindowListener(element); JTextField label = new JTextField(20); JTextField name = new JTextField(20); if (ref != null) { this.ab = ref; label.setText(ref.getLabel()); name.setText(ref.getName()); } else { this.ab = original; label.setText(ab.getLabel()); name.setText(ab.getName()); } reference = new JCheckBox(); knockedOut = new JCheckBox(); colorButton = new JButton("Colour"); hideNeighbours = new JButton("Hide all Neighbours"); showNeighbours = new JButton("Show all Neighbours"); parametersButton = new JButton("Parameters"); showLabels = new JButton("Show Labels"); colorButton.setBackground(ab.getColor()); colorButton.setToolTipText("Colour"); colorButton.setActionCommand("colour"); colorButton.addActionListener(this); // System.out.println("label: "+ab.getLabel()); // System.out.println("name: "+ab.getName()); label.setName("label"); name.setName("name"); label.addFocusListener(pwl); name.addFocusListener(pwl); reference.setSelected(ab.isReference()); reference.setToolTipText("Set this element to a reference"); reference.setActionCommand("reference"); reference.addActionListener(this); MigLayout headerlayout = new MigLayout("fillx", "[right]rel[grow,fill]", ""); JPanel headerPanel = new JPanel(headerlayout); // headerPanel.setBackground(new Color(192, 215, 227)); headerPanel.add(new JLabel(ab.getBiologicalElement()), ""); headerPanel.add(new JSeparator(), "gap 10"); MigLayout layout = new MigLayout("fillx", "[grow,fill]", ""); p.setLayout(layout); p.add(new JLabel("Element"), "gap 5 "); p.add(new JLabel(ab.getBiologicalElement()), "wrap,span 3"); p.add(new JLabel("Label"), "gap 5 "); p.add(label, "wrap,span 3"); p.add(new JLabel("Name"), "gap 5 "); p.add(name, "wrap ,span 3"); // JCheckBox transitionfire = new JCheckBox("Should transition fire:", // true); // JTextField transitionStatement = new JTextField("true"); if (ab.isVertex()) { BiologicalNodeAbstract bna = (BiologicalNodeAbstract) original; String lbl = ""; if (bna.hasRef()) { lbl = bna.getID() + "_" + bna.getRef().getLabel(); } p.add(new JLabel("Reference:"), "gap 5 "); p.add(new JLabel(lbl), "wrap ,span 3"); if (bna.hasRef()) { this.deleteRef = new JButton("Delete Reference"); deleteRef.setToolTipText("Delete Reference"); deleteRef.setActionCommand("deleteRef"); deleteRef.addActionListener(this); p.add(deleteRef); this.pickOrigin = new JButton("Highlight Origin"); pickOrigin.setToolTipText("Highlight Origin"); pickOrigin.setActionCommand("pickOrigin"); pickOrigin.addActionListener(this); p.add(pickOrigin); } else { this.chooseRef = new JButton("Choose Reference"); chooseRef.setToolTipText("Choose Reference"); chooseRef.setActionCommand("chooseRef"); chooseRef.addActionListener(this); p.add(chooseRef); if (bna.getRefs().size() > 0) { this.pickRefs = new JButton("Highlight References"); pickRefs.setToolTipText("Highlight References"); pickRefs.setActionCommand("pickRefs"); pickRefs.addActionListener(this); p.add(pickRefs); } } showLabels.setToolTipText("Show all Labels"); showLabels.setActionCommand("showLabels"); showLabels.addActionListener(this); p.add(showLabels, "wrap"); JComboBox<String> compartment = new JComboBox<String>(); addCompartmentItems(compartment); AutoCompleteDecorator.decorate(compartment); compartment.setSelectedItem(bna.getCompartment()); compartment.addItemListener(this); p.add(new JLabel("Compartment"), "gap 5 "); p.add(compartment, "wrap ,span 3"); // ADDing Attributes (for all nodes) // Show Database IDs JTextArea dbids = new JTextArea(); String dbidstring = new String(); dbids.setEditable(false); dbids.setFont(dbids.getFont().deriveFont(Font.BOLD)); dbids.setBackground(Color.WHITE); p.add(new JLabel("IDs known:"), "gap 5"); p.add(dbids, "wrap, span 3"); // Show Experiment names and values JTextArea experiments = new JTextArea(); String experimentstring = new String(); experiments.setEditable(false); experiments.setBackground(Color.WHITE); p.add(new JLabel("Dataset:"), "gap 5"); p.add(experiments, "wrap, span 3"); // Show GO annotations JTextArea goannoations = new JTextArea(); String annotationstring = new String(); goannoations.setEditable(false); goannoations.setForeground(Color.BLUE); goannoations.setBackground(Color.WHITE); p.add(new JLabel("Gene Ontology:"), "gap 5"); p.add(goannoations, "wrap, span 3"); // Show graph properties (local property) JTextArea graphproperties = new JTextArea(); String propertiesstring = new String(); graphproperties.setEditable(false); graphproperties.setForeground(new Color(255, 55, 55)); graphproperties.setBackground(Color.WHITE); p.add(new JLabel("Graph properties:"), "gap 5"); p.add(graphproperties, "wrap, span 3"); // JTextField aaSequence = new JTextField(20); // aaSequence.setText(protein.getAaSequence()); // aaSequence.setName("protein"); // aaSequence.addFocusListener(pwl); // p.add(new JLabel("AA-Sequence"), "gap 5 "); // p.add(aaSequence, "wrap, span 3"); String atname, atsvalue; double atdvalue; ArrayList<String> experimententries = new ArrayList<>(), databaseidentries = new ArrayList<>(), annotationentries = new ArrayList<>(), graphpropertiesentries = new ArrayList<>(); for (NodeAttribute att : bna.getNodeAttributes()) { atname = att.getName(); atsvalue = att.getStringvalue(); atdvalue = att.getDoublevalue(); switch (att.getType()) { case NodeAttributeTypes.EXPERIMENT: experimententries.add(atname + ":\t" + atdvalue + "\n"); break; case NodeAttributeTypes.DATABASE_ID: databaseidentries.add(atname + ":\t" + atsvalue + "\n"); break; case NodeAttributeTypes.ANNOTATION: annotationentries.add(atname + ":\t" + atsvalue + "\n"); break; case NodeAttributeTypes.GRAPH_PROPERTY: graphpropertiesentries.add(atname + ":\t" + atdvalue + "\n"); break; default: break; } } // Sort for more convenient display Collections.sort(experimententries); for (String exp : experimententries) experimentstring += exp; Collections.sort(databaseidentries); for (String dbid : databaseidentries) dbidstring += dbid; Collections.sort(annotationentries); for (String ann : annotationentries) annotationstring += ann; Collections.sort(graphpropertiesentries); for (String gprop : graphpropertiesentries) propertiesstring += gprop; experiments.setText(experimentstring); dbids.setText(dbidstring); goannoations.setText(annotationstring); graphproperties.setText(propertiesstring); if (ab instanceof PathwayMap) { p.add(new JLabel("Linked to Pathway"), "gap 5 "); boolean b = ((PathwayMap) ab).getPathwayLink() == null; JCheckBox linked = new JCheckBox("", !b); linked.setToolTipText( "Shows whether there is a connected Pathway in Memory to this Map (uncheck the Box to delete that Pathway)"); linked.setActionCommand("pathwayLink"); linked.addActionListener(this); linked.setEnabled(!b); p.add(linked, "wrap ,span 3"); } else if (ab instanceof Protein) { Protein protein = (Protein) ab; JTextField aaSequence = new JTextField(20); aaSequence.setText(protein.getAaSequence()); aaSequence.setName("protein"); aaSequence.addFocusListener(pwl); p.add(new JLabel("AA-Sequence"), "gap 5 "); p.add(aaSequence, "wrap, span 3"); } else if (ab instanceof DNA) { DNA dna = (DNA) ab; JTextField ntSequence = new JTextField(20); ntSequence.setText(dna.getNtSequence()); ntSequence.setName("dna"); ntSequence.addFocusListener(pwl); p.add(new JLabel("NT-Sequence"), "gap 5 "); p.add(ntSequence, "wrap, span 3"); } else if (ab instanceof Gene) { Gene dna = (Gene) ab; JTextField ntSequence = new JTextField(20); ntSequence.setText(dna.getNtSequence()); ntSequence.setName("gene"); ntSequence.addFocusListener(pwl); p.add(new JLabel("NT-Sequence"), "gap 5 "); p.add(ntSequence, "wrap, span 3"); } else if (ab instanceof RNA) { RNA rna = (RNA) ab; JTextField ntSequence = new JTextField(20); ntSequence.setText(rna.getNtSequence()); ntSequence.setName("rna"); ntSequence.addFocusListener(pwl); p.add(new JLabel("NT-Sequence"), "gap 5 "); p.add(ntSequence, "wrap, span 3"); } else if (ab instanceof Place) { p.add(new JLabel("ID"), "gap 5 "); JTextField id = new JTextField(20); id.setText("P" + Integer.toString(ab.getID())); id.setEditable(false); p.add(id, "wrap ,span 3"); Place place = (Place) ab; JLabel lswitchPlace = new JLabel("Place Type"); JComboBox<String> placeList = new JComboBox<String>(new String[] {"discrete", "continuous"}); if (place.isDiscrete()) placeList.setSelectedItem("discrete"); else placeList.setSelectedItem("continuous"); placeList.setName("placeList"); placeList.addFocusListener(pwl); p.add(lswitchPlace, "gap 5 "); p.add(placeList, "wrap"); MyJFormattedTextField token; MyJFormattedTextField tokenStart; JLabel lblTokenStart = new JLabel("Token Start"); if (place.isDiscrete()) { token = new MyJFormattedTextField(MyNumberFormat.getIntegerFormat()); tokenStart = new MyJFormattedTextField(MyNumberFormat.getIntegerFormat()); tokenMin = new MyJFormattedTextField(MyNumberFormat.getIntegerFormat()); tokenMax = new MyJFormattedTextField(MyNumberFormat.getIntegerFormat()); token.setText((int) place.getToken() + ""); tokenStart.setText((int) place.getTokenStart() + ""); tokenMin.setText((int) place.getTokenMin() + ""); tokenMax.setText((int) place.getTokenMax() + ""); } else { token = new MyJFormattedTextField(MyNumberFormat.getDecimalFormat()); tokenStart = new MyJFormattedTextField(MyNumberFormat.getDecimalFormat()); tokenMin = new MyJFormattedTextField(MyNumberFormat.getDecimalFormat()); tokenMax = new MyJFormattedTextField(MyNumberFormat.getDecimalFormat()); token.setText(place.getToken() + ""); tokenStart.setText(place.getTokenStart() + ""); tokenMin.setText(place.getTokenMin() + ""); tokenMax.setText(place.getTokenMax() + ""); } JLabel lblToken = new JLabel("Token"); token.setName("token"); // token.addFocusListener(pwl); token.setEditable(false); token.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT); tokenStart.setName("tokenStart"); tokenStart.setFocusLostBehavior(JFormattedTextField.COMMIT); tokenStart.addFocusListener(pwl); tokenMin.setName("tokenMin"); tokenMin.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT); tokenMin.addFocusListener(pwl); JLabel lblTokenMin = new JLabel("min Tokens"); tokenMax.setName("tokenMax"); tokenMax.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT); tokenMax.addFocusListener(pwl); JLabel lblTokenMax = new JLabel("max Tokens"); p.add(lblToken, "gap 5 "); p.add(token, "wrap"); p.add(lblTokenStart, "gap 5 "); p.add(tokenStart, ""); constCheck = new JCheckBox("constant"); constCheck.setActionCommand("constCheck"); constCheck.addActionListener(this); constCheck.setSelected(place.isConstant()); p.add(constCheck, "wrap"); if (constCheck.isSelected()) { tokenMin.setEnabled(false); tokenMax.setEnabled(false); } p.add(lblTokenMin, "gap 5 "); p.add(tokenMin, "wrap"); p.add(lblTokenMax, "gap 5"); p.add(tokenMax, "wrap"); } else if (ab instanceof Transition) { JLabel lswitchTrans = new JLabel("Transition Type"); JComboBox<String> transList = new JComboBox<String>( new String[] { DiscreteTransition.class.getName(), ContinuousTransition.class.getName(), StochasticTransition.class.getName() }); transList.setSelectedItem(ab.getClass().getCanonicalName()); transList.setName("transList"); transList.addFocusListener(pwl); p.add(lswitchTrans, "gap 5"); p.add(transList, "wrap"); JTextField firingCondition = new JTextField(4); JLabel lblFiringCondition = new JLabel("Firing Condition"); firingCondition.setText(((Transition) ab).getFiringCondition()); firingCondition.setName("firingCondition"); firingCondition.addFocusListener(pwl); p.add(lblFiringCondition, "gap 5"); p.add(firingCondition, "wrap"); if (ab instanceof DiscreteTransition) { DiscreteTransition trans = (DiscreteTransition) ab; JTextField delay = new JTextField(4); JLabel lbldelay = new JLabel("Delay"); delay.setText(trans.getDelay() + ""); delay.setName("delay"); delay.addFocusListener(pwl); p.add(lbldelay, "gap 5"); p.add(delay, "wrap"); } else if (ab instanceof StochasticTransition) { StochasticTransition trans = (StochasticTransition) ab; String[] disStrings = {"norm", "exp"}; // Create the combo box, select item at index 4. // Indices start at 0, so 4 specifies the pig. JComboBox<String> distributionList = new JComboBox<String>(disStrings); distributionList.setSelectedItem(trans.getDistribution()); distributionList.setName("disList"); distributionList.addFocusListener(pwl); p.add(new JLabel("Distribution"), "gap 5"); p.add(distributionList, "wrap"); } else if (ab instanceof ContinuousTransition) { ContinuousTransition trans = (ContinuousTransition) ab; JTextField maxSpeed = new JTextField(4); JLabel lblMaxSpeed = new JLabel("Maximum Speed"); maxSpeed.setText(trans.getMaximumSpeed()); maxSpeed.setName("maximumSpeed"); maxSpeed.addFocusListener(pwl); p.add(lblMaxSpeed, "gap 5"); p.add(maxSpeed, "wrap"); if (trans.isKnockedOut()) { maxSpeed.setEnabled(false); } } } } else if (ab.isEdge()) { // System.out.println("edge"); if (ab instanceof PNEdge) { PNEdge e = (PNEdge) ab; JTextField prob = new JTextField(4); prob.setText(e.getActivationProbability() + ""); prob.setName("activationProb"); prob.addFocusListener(pwl); JLabel lblProb = new JLabel("activation Probability"); JTextField function = new JTextField(5); function.setText(e.getFunction()); function.setName("function"); function.addFocusListener(pwl); JLabel lblpassingTokens = new JLabel("Edge Function"); JTextField lowBoundary = new JTextField(5); lowBoundary.setText(e.getLowerBoundary() + ""); lowBoundary.setName("lowBoundary"); lowBoundary.addFocusListener(pwl); JLabel lblLow = new JLabel("lower Boundary"); JTextField upBoundary = new JTextField(5); upBoundary.setText(e.getUpperBoundary() + ""); upBoundary.setName("upBoundary"); upBoundary.addFocusListener(pwl); JLabel lblUp = new JLabel("upper Boundary"); // String[] types = { "discrete", "continuous", "inhibition" }; // Create the combo box, select item at index 4. // Indices start at 0, so 4 specifies the pig. // JLabel typeList = new JComboBox(types); p.add(new JLabel("Edge Type"), "gap 5 "); p.add(new JLabel(e.getType()), "wrap"); JButton dirChanger = new JButton("Change Direction"); dirChanger.setActionCommand("dirChanger"); dirChanger.addActionListener(this); p.add(dirChanger, "wrap"); p.add(lblProb, "gap 5"); p.add(prob, "wrap"); p.add(lblpassingTokens, "gap 5"); p.add(function, "wrap"); p.add(lblLow, "gap 5"); p.add(lowBoundary, "wrap"); p.add(lblUp, "gap 5"); p.add(upBoundary, "wrap"); } } p.add(new JLabel("Reference"), "gap 5 "); p.add(reference, "wrap, span 3"); if (ab instanceof Transition) { knockedOut.setSelected(((Transition) ab).isKnockedOut()); knockedOut.setToolTipText("Knock out"); knockedOut.setActionCommand("knockedOut"); knockedOut.addActionListener(this); p.add(new JLabel("Knocked out"), "gap 5 "); p.add(knockedOut, "wrap ,span 3"); } if (ab.isVertex()) { hideNeighbours.setToolTipText("Sets all Neighbors of the selected Node to Reference"); hideNeighbours.setActionCommand("hideNeighbours"); hideNeighbours.addActionListener(this); hideNeighbours.setMaximumSize(new Dimension(120, 30)); showNeighbours.setToolTipText("Delete Reference flag of all Neighbours of the current Node"); showNeighbours.setActionCommand("showNeighbours"); showNeighbours.addActionListener(this); showNeighbours.setMaximumSize(new Dimension(120, 30)); p.add(showNeighbours); p.add(hideNeighbours); } parametersButton.setToolTipText("Show all Parameters"); parametersButton.setActionCommand("showParameters"); parametersButton.addActionListener(this); p.add(parametersButton); p.add(colorButton, "gap 5"); }