Search in sources :

Example 1 with MotionLink

use of org.jwildfire.create.tina.dance.motion.MotionLink in project JWildfire by thargor6.

the class DancingFractalsController method replaceFlameFromEditorBtn_clicked.

public void replaceFlameFromEditorBtn_clicked(Flame pFlame) {
    if (pFlame != null) {
        Flame flame = poolFlameHolder.getFlame();
        if (flame != null) {
            int idx = flamePropertiesTree.getSelectionRows()[0];
            // cant remove the flame by object reference because its a clone
            Flame newFlame = validateDancingFlame(pFlame.makeCopy());
            Flame oldFlame = project.getFlames().get(idx);
            for (Motion motion : project.getMotions()) {
                for (MotionLink link : motion.getMotionLinks()) {
                    if (link.getProperyPath().getFlame().isEqual(oldFlame)) {
                        link.getProperyPath().setFlame(newFlame);
                    }
                }
            }
            project.getFlames().set(idx, newFlame);
            refreshProjectFlames();
            if (project.getFlames().size() == 0) {
                flamePropertiesTree_changed(null);
            } else {
                try {
                    flamePropertiesTree.setSelectionRow(idx);
                } catch (Exception ex) {
                }
            }
            enableControls();
        }
    }
}
Also used : Motion(org.jwildfire.create.tina.dance.motion.Motion) MotionLink(org.jwildfire.create.tina.dance.motion.MotionLink) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 2 with MotionLink

use of org.jwildfire.create.tina.dance.motion.MotionLink in project JWildfire by thargor6.

the class DancingFractalsController method linkMotionBtn_clicked.

public void linkMotionBtn_clicked() {
    Motion currMotion = getSelectedMotion();
    if (currMotion != null && flamePropertiesTreeService.isPlainPropertySelected(flamePropertiesTree)) {
        FlamePropertyPath propertyPath = flamePropertiesTreeService.getSelectedPropertyPath(flamePropertiesTree);
        currMotion.getMotionLinks().add(new MotionLink(propertyPath));
        refreshMotionLinksTable();
        int selectRow = currMotion.getMotionLinks().size() - 1;
        motionLinksTable.getSelectionModel().setSelectionInterval(selectRow, selectRow);
        enableControls();
    }
}
Also used : Motion(org.jwildfire.create.tina.dance.motion.Motion) MotionLink(org.jwildfire.create.tina.dance.motion.MotionLink) FlamePropertyPath(org.jwildfire.create.tina.dance.model.FlamePropertyPath)

Example 3 with MotionLink

use of org.jwildfire.create.tina.dance.motion.MotionLink in project JWildfire by thargor6.

the class DancingFractalsController method refreshMotionLinksTable.

private void refreshMotionLinksTable() {
    final int COL_FLAME = 0;
    final int COL_PROPERTY = 1;
    final Motion currMotion = getSelectedMotion();
    motionLinksTable.setModel(new DefaultTableModel() {

        private static final long serialVersionUID = 1L;

        @Override
        public int getRowCount() {
            return currMotion != null ? currMotion.getMotionLinks().size() : 0;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public String getColumnName(int columnIndex) {
            switch(columnIndex) {
                case COL_FLAME:
                    return "Flame";
                case COL_PROPERTY:
                    return "Property";
            }
            return null;
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            MotionLink motionLink = rowIndex < currMotion.getMotionLinks().size() ? currMotion.getMotionLinks().get(rowIndex) : null;
            if (motionLink != null) {
                switch(columnIndex) {
                    case COL_FLAME:
                        return flamePropertiesTreeService.getFlameCaption(motionLink.getProperyPath().getFlame());
                    case COL_PROPERTY:
                        return motionLink.getProperyPath().getPath();
                }
            }
            return null;
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    });
    motionLinksTable.getTableHeader().setFont(motionLinksTable.getFont());
    motionLinksTable.getColumnModel().getColumn(COL_FLAME).setWidth(80);
    motionLinksTable.getColumnModel().getColumn(COL_PROPERTY).setPreferredWidth(120);
}
Also used : Motion(org.jwildfire.create.tina.dance.motion.Motion) MotionLink(org.jwildfire.create.tina.dance.motion.MotionLink) DefaultTableModel(javax.swing.table.DefaultTableModel)

Example 4 with MotionLink

use of org.jwildfire.create.tina.dance.motion.MotionLink in project JWildfire by thargor6.

the class DancingFlameProject method getMotions.

public List<Motion> getMotions(Flame pFlame) {
    List<Motion> res = new ArrayList<Motion>();
    for (Motion motion : motions) {
        for (MotionLink link : motion.getMotionLinks()) {
            if (link.getProperyPath().getFlame().isEqual(pFlame)) {
                Motion currMotion = motion;
                int iter = 0;
                while (currMotion != null) {
                    res.add(currMotion);
                    Motion refMotion = currMotion;
                    currMotion = null;
                    for (Motion nextMotion : getMotions()) {
                        if (nextMotion.getParent() == refMotion) {
                            currMotion = nextMotion;
                            break;
                        }
                    }
                    iter++;
                    if (iter > 100) {
                        throw new RuntimeException("Probably endless loop detected");
                    }
                }
                break;
            }
        }
    }
    return res;
}
Also used : Motion(org.jwildfire.create.tina.dance.motion.Motion) MotionLink(org.jwildfire.create.tina.dance.motion.MotionLink) ArrayList(java.util.ArrayList)

Aggregations

Motion (org.jwildfire.create.tina.dance.motion.Motion)4 MotionLink (org.jwildfire.create.tina.dance.motion.MotionLink)4 ArrayList (java.util.ArrayList)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1 Flame (org.jwildfire.create.tina.base.Flame)1 FlamePropertyPath (org.jwildfire.create.tina.dance.model.FlamePropertyPath)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1