Search in sources :

Example 6 with Motion

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

the class DancingFractalsController method motionTableClicked.

public void motionTableClicked() {
    if (!refreshing) {
        if (motionPropertyPnl != null) {
            motionPropertyRootPnl.remove(motionPropertyPnl);
            motionPropertyPnl = null;
        }
        if (project.getMotions().size() > 0 && motionTable.getSelectedRow() >= 0 && motionTable.getSelectedRow() < project.getMotions().size()) {
            Motion motion = project.getMotions().get(motionTable.getSelectedRow());
            @SuppressWarnings("rawtypes") Map<Class, PropertyEditor> editors = new HashMap<Class, PropertyEditor>();
            editors.put(Motion.class, new MotionTypeEditor(project.getMotions()));
            motionPropertyPnl = new PropertyPanel(motion, editors);
            motionPropertyPnl.setDescriptionVisible(false);
            PropertyChangeListener listener = new PropertyChangeListener() {

                public void propertyChange(PropertyChangeEvent evt) {
                    refreshing = true;
                    try {
                        int oldSel = motionTable.getSelectedRow();
                        refreshMotionTable();
                        motionTable.getSelectionModel().setSelectionInterval(oldSel, oldSel);
                        enableControls();
                    } finally {
                        refreshing = false;
                    }
                }
            };
            motionPropertyPnl.addPropertySheetChangeListener(listener);
            motionPropertyRootPnl.add(motionPropertyPnl, BorderLayout.CENTER);
            enableControls();
        }
    }
    refreshMotionLinksTable();
    motionPropertyRootPnl.invalidate();
    motionPropertyRootPnl.validate();
}
Also used : Motion(org.jwildfire.create.tina.dance.motion.Motion) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) HashMap(java.util.HashMap) ComboBoxPropertyEditor(com.l2fprod.common.beans.editor.ComboBoxPropertyEditor) PropertyEditor(java.beans.PropertyEditor) PropertyPanel(org.jwildfire.swing.PropertyPanel)

Example 7 with Motion

use of org.jwildfire.create.tina.dance.motion.Motion 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 8 with Motion

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

the class DancingFractalsController method addMotionBtn_clicked.

public void addMotionBtn_clicked() {
    try {
        MotionType motionType = (MotionType) addMotionCmb.getSelectedItem();
        if (motionType != null) {
            Motion newMotion = motionType.getMotionClass().newInstance();
            project.getMotions().add(newMotion);
            boolean oldRefreshing = refreshing;
            refreshing = true;
            try {
                refreshMotionTable();
            } finally {
                refreshing = oldRefreshing;
            }
            int selectRow = project.getMotions().size() - 1;
            motionTable.getSelectionModel().setSelectionInterval(selectRow, selectRow);
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : Motion(org.jwildfire.create.tina.dance.motion.Motion) MotionType(org.jwildfire.create.tina.dance.motion.MotionType)

Example 9 with Motion

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

the class DancingFractalsController method renameMotionBtn_clicked.

public void renameMotionBtn_clicked() {
    int row = motionTable.getSelectedRow();
    if (row >= 0 && row < project.getMotions().size()) {
        Motion motion = project.getMotions().get(row);
        String s = StandardDialogs.promptForText(rootPanel, "Please enter the new title:", motion.getDisplayLabel());
        if (s != null) {
            motion.setCaption(s);
            refreshMotionTable();
            if (row >= project.getMotions().size()) {
                row--;
            }
            if (row >= 0) {
                motionTable.getSelectionModel().setSelectionInterval(row, row);
            }
            motionTableClicked();
            enableControls();
        }
    }
}
Also used : Motion(org.jwildfire.create.tina.dance.motion.Motion)

Example 10 with Motion

use of org.jwildfire.create.tina.dance.motion.Motion 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)11 MotionLink (org.jwildfire.create.tina.dance.motion.MotionLink)4 DefaultTableModel (javax.swing.table.DefaultTableModel)2 Flame (org.jwildfire.create.tina.base.Flame)2 FlamePropertyPath (org.jwildfire.create.tina.dance.model.FlamePropertyPath)2 ComboBoxPropertyEditor (com.l2fprod.common.beans.editor.ComboBoxPropertyEditor)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 PropertyEditor (java.beans.PropertyEditor)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 RecordedFFT (org.jwildfire.create.tina.audio.RecordedFFT)1 DancingFlameProject (org.jwildfire.create.tina.dance.DancingFlameProject)1 MotionType (org.jwildfire.create.tina.dance.motion.MotionType)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1 PropertyPanel (org.jwildfire.swing.PropertyPanel)1