private String onMousePressed(MouseEvent e, Bundle data) { // read data from bundle // MouseEvent e = (MouseEvent) data.getObject(DataKey.MouseEvent.name()); // Set<SoundCircle> scset = (Set<SoundCircle>) data.getObject(DataKey.SoundCircleSet.name()); int timeValue = (int) data.getObject(DataKey.TimeValue.name()); // if (null == e || null == scset || null == data.getObject(DataKey.TimeValue.name())) // return null; // find a SC which contains the mouse at current time /*for (SoundCircle sc : soundCircleTable.values()) { // if a SC contains the mouse, stay in the current state. if (sc.contains(e.getPoint(), timeValue)) return getName(); }*/ SoundCircle prevGeneratedSC = soundCircleTable.get(soundCircleListener); if (null != prevGeneratedSC && prevGeneratedSC.centers.size() > 0) return getName(); /*if(prevGeneratedSC.contains(e.getPoint(), timeValue)) return getName(); */ System.out.println("prev SC = " + prevGeneratedSC); // if(null != prevGeneratedSC) // prevGeneratedSC.removeCirclesAtAndAfter(timeValue); // mouse is outside of sound circles. Set new sound circle center and radius newSoundCircleRadius = 0; newSoundCircleCenter = e.getPoint(); return DrawingSC.class.getName(); }
private String onMouseClicked(MouseEvent e, Bundle data) { // read data from bundle // Set<SoundCircle> scset = (Set<SoundCircle>) data.getObject(DataKey.SoundCircleSet.name()); int timeValue = (int) data.getObject(DataKey.TimeValue.name()); Component c = (Component) data.getObject(DataKey.ComponentToRepaint.name()); // if(null == e || null == scset || null == data.getObject(DataKey.TimeValue.name())) // return null; // find a SC which contains the mouse at current time SoundCircle sc = null; for (SoundCircle s : soundCircleTable.values()) { // if a SC contains the mouse, stay in the current state. if (s.contains(e.getPoint(), timeValue)) { sc = s; break; } } if (null == sc) return getName(); // choose the SC selectedSC = sc; c.repaint(); return SCchoosen.class.getName(); }
private String onMouseDragged(MouseEvent e, Bundle data) { int timeValue = (int) data.getObject(DataKey.TimeValue.name()); Component c = (Component) data.getObject(DataKey.ComponentToRepaint.name()); selectedSC.addCircleAt(timeValue, e.getPoint()); c.repaint(); return SCchoosen.class.getName(); }
private String onPasteSoundCircle(Bundle data) { if (null == scPositionClipboard) return getName(); int time = (int) data.getObject(DataKey.TimeValue.name()); Component c = (Component) data.getObject(DataKey.ComponentToRepaint.name()); selectedSC.addCircleAt(time, scPositionClipboard); c.repaint(); return getName(); }
private String onDeleteSoundCircle(Bundle data) { int time = (int) data.getObject(DataKey.TimeValue.name()); Component c = (Component) data.getObject(DataKey.ComponentToRepaint.name()); selectedSC.removeCircles(); // soundCircleTable.remove selectedSC = null; c.repaint(); return PaintingSC.class.getName(); }
private String onMouseReleased(MouseEvent e, Bundle data) { // generate SC and notify the SC to soundPanel int time = (int) data.getObject(DataKey.TimeValue.name()); SoundCircle sc = new SoundCircle(time, newSoundCircleRadius, newSoundCircleCenter, newSoundCircleColor); soundCircleListener.onGenerated(sc); soundCircleTable.put(soundCircleListener, sc); newSoundCircleCenter = null; return PaintingSC.class.getName(); }
private String onMouseClicked(MouseEvent e, Bundle data) { int timeValue = (int) data.getObject(DataKey.TimeValue.name()); Component c = (Component) data.getObject(DataKey.ComponentToRepaint.name()); // find a SC which contains the mouse at current time for (SoundCircle sc : soundCircleTable.values()) { // if a SC contains the mouse, do nothing and stay in the current state. if (sc.contains(e.getPoint(), timeValue)) return getName(); } selectedSC = null; c.repaint(); return PaintingSC.class.getName(); }
private String onCopySoundCircle(Bundle data) { int time = (int) data.getObject(DataKey.TimeValue.name()); scPositionClipboard = selectedSC.getCirclePointAt(time); return getName(); }