Пример #1
0
  private void fillGUI() {
    Object[] attributes;
    boolean enabled;
    if (context != null) {
      attributes = this.context.getAttributes().toArray();
      enabled = true;
    } else {
      attributes = new Object[] {"No context available"};
      enabled = false;
    }

    sequenceColumnChooser.setModel(new DefaultComboBoxModel(attributes));
    sequenceColumnChooser.setEnabled(enabled);

    timelineColumnChooser.setModel(new DefaultComboBoxModel(attributes));
    timelineColumnChooser.setEnabled(enabled);
    if (context != null) {
      timelineColumnChooser.setSelectedIndex(Math.min(attributes.length - 1, 1));
    }

    calculateValueLists();
    fillSequenceChooser();

    setButtonStates(!enabled);
  }
Пример #2
0
  private void calculateValueLists() {
    sequenceValues = new ArrayList<>();
    timelineValues = new ArrayList<>();

    final Object selectedSequenceColumn = this.sequenceColumnChooser.getSelectedItem();
    if (!(selectedSequenceColumn instanceof ManyValuedAttribute)) {
      return;
    }
    final ManyValuedAttribute sequenceAttribute = (ManyValuedAttribute) selectedSequenceColumn;
    final ManyValuedAttribute timelineAttribute =
        (ManyValuedAttribute) timelineColumnChooser.getSelectedItem();

    for (final FCAElement object : this.context.getObjects()) {
      Value value = this.context.getRelationship(object, sequenceAttribute);
      if (!sequenceValues.contains(value) && value != null) {
        boolean inserted = false;
        final ListIterator<Value> seqIt = sequenceValues.listIterator();
        while (seqIt.hasNext()) {
          final Value curValue = seqIt.next();
          if (value.isLesserThan(curValue)) {
            if (seqIt.hasPrevious()) {
              seqIt.previous();
            }
            seqIt.add(value);
            inserted = true;
            break;
          }
        }
        if (!inserted) {
          seqIt.add(value);
        }
      }
      value = this.context.getRelationship(object, timelineAttribute);
      if (!timelineValues.contains(value) && value != null) {
        boolean inserted = false;
        final ListIterator<Value> tlIt = timelineValues.listIterator();
        while (tlIt.hasNext()) {
          final Value curValue = tlIt.next();
          if (curValue != null && value.isLesserThan(curValue)) {
            if (tlIt.hasPrevious()) {
              tlIt.previous();
            }
            tlIt.add(value);
            inserted = true;
            break;
          }
        }
        if (!inserted) {
          tlIt.add(value);
        }
      }
    }
  }
Пример #3
0
  private List<ArrayList<FCAElement>> calculateObjectSequences() {
    final ManyValuedAttribute sequenceAttribute =
        (ManyValuedAttribute) sequenceColumnChooser.getSelectedItem();
    final ManyValuedAttribute timelineAttribute =
        (ManyValuedAttribute) timelineColumnChooser.getSelectedItem();

    final List<ArrayList<FCAElement>> objectSequences = new ArrayList<>();

    // initialise sequences with empty lists
    for (Value ignored : sequenceValues) {
      objectSequences.add(new ArrayList<FCAElement>());
    }

    // go over time
    for (Value timelineValue : timelineValues) {
      // try to find matching object for each sequence
      Iterator<Value> seqValIt = sequenceValues.iterator();
      final Iterator<ArrayList<FCAElement>> seqIt = objectSequences.iterator();
      while (seqValIt.hasNext()) {
        final Value sequenceValue = seqValIt.next();
        final List<FCAElement> sequence = seqIt.next();
        boolean objectFound = false;
        for (FCAElement object : this.context.getObjects()) {
          if (this.context.getRelationship(object, sequenceAttribute) != null
              && this.context.getRelationship(object, sequenceAttribute).equals(sequenceValue)
              && this.context.getRelationship(object, timelineAttribute) != null
              && this.context.getRelationship(object, timelineAttribute).equals(timelineValue)) {
            sequence.add(object);
            objectFound = true;
            break;
          }
        }
        if (!objectFound) {
          sequence.add(null);
        }
      }
    }

    return objectSequences;
  }
Пример #4
0
  private JPanel createBasicSettingsPanel() {
    final JLabel sequenceColumnLabel = new JLabel("Sequence Column:");
    sequenceColumnChooser = new JComboBox();
    sequenceColumnChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            calculateValueLists();
            fillSequenceChooser();
          }
        });

    final JLabel timelineLabel = new JLabel("Timeline Column:");
    timelineColumnChooser = new JComboBox();
    timelineColumnChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            calculateValueLists();
            fillSequenceChooser();
          }
        });

    final JLabel sequenceLabel = new JLabel("Sequence:");
    sequenceToShowChooser = new JList<>();

    serializeSequencesBox = new JCheckBox("Serialize when stepping/animating");

    final JPanel basicSettingsPanel = new JPanel(new GridBagLayout());
    int r = 0;
    basicSettingsPanel.add(
        sequenceColumnLabel,
        new GridBagConstraints(
            0,
            r,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            DEFAULT_LABEL_INSETS,
            0,
            0));
    r++;
    basicSettingsPanel.add(
        sequenceColumnChooser,
        new GridBagConstraints(
            0,
            r,
            1,
            1,
            1,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL,
            DEFAULT_FIELD_INSETS,
            0,
            0));
    r++;
    basicSettingsPanel.add(
        timelineLabel,
        new GridBagConstraints(
            0,
            r,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            DEFAULT_LABEL_INSETS,
            0,
            0));
    r++;
    basicSettingsPanel.add(
        timelineColumnChooser,
        new GridBagConstraints(
            0,
            r,
            1,
            1,
            1,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL,
            DEFAULT_FIELD_INSETS,
            0,
            0));
    r++;
    basicSettingsPanel.add(
        sequenceLabel,
        new GridBagConstraints(
            0,
            r,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            DEFAULT_LABEL_INSETS,
            0,
            0));
    r++;
    basicSettingsPanel.add(
        sequenceToShowChooser,
        new GridBagConstraints(
            0,
            r,
            1,
            1,
            1,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL,
            DEFAULT_FIELD_INSETS,
            0,
            0));
    r++;
    basicSettingsPanel.add(
        serializeSequencesBox,
        new GridBagConstraints(
            0,
            r,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    r++;
    basicSettingsPanel.add(
        new JPanel(),
        new GridBagConstraints(
            0,
            r,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            DEFAULT_SPACER_INSETS,
            0,
            0));
    return basicSettingsPanel;
  }