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); } } } }
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; }