annotate java/src/uk/ac/qmul/eecs/ccmi/diagrammodel/ElementChangedEvent.java @ 8:ea7885bd9bff tip

fixed bug : render solid line as dotted/dashed when moving the stylus from dotted/dashed to solid
author ccmi-guest
date Thu, 03 Jul 2014 16:12:20 +0100
parents d66dd5880081
children
rev   line source
fiore@0 1 /*
fiore@0 2 CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
fiore@0 3
fiore@0 4 Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
fiore@0 5
fiore@0 6 This program is free software: you can redistribute it and/or modify
fiore@0 7 it under the terms of the GNU General Public License as published by
fiore@0 8 the Free Software Foundation, either version 3 of the License, or
fiore@0 9 (at your option) any later version.
fiore@0 10
fiore@0 11 This program is distributed in the hope that it will be useful,
fiore@0 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
fiore@0 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fiore@0 14 GNU General Public License for more details.
fiore@0 15
fiore@0 16 You should have received a copy of the GNU General Public License
fiore@0 17 along with this program. If not, see <http://www.gnu.org/licenses/>.
fiore@0 18 */
fiore@0 19 package uk.ac.qmul.eecs.ccmi.diagrammodel;
fiore@0 20
fiore@0 21 import java.util.EventObject;
fiore@0 22
fiore@0 23 /**
fiore@3 24 * ElementChangedEvent is used to notify the model listeners that an element ({@code DiagramNode}
fiore@3 25 * or {@code DiagramEdge}) in the model has been changed (e.g. it has a new name).
fiore@0 26 *
fiore@0 27 */
fiore@0 28 @SuppressWarnings("serial")
fiore@0 29 public class ElementChangedEvent extends EventObject {
fiore@0 30
fiore@3 31 /**
fiore@3 32 * Creates a new instance of {@code ElementChangedEvent}
fiore@3 33 *
fiore@3 34 * @param element the element that has been changed
fiore@5 35 * @param args the arguments of this change event, if any
fiore@3 36 * @param changeType it's a {@code String} identifying the change type. Subclasses of {@code DiagramNode} and
fiore@3 37 * {@code DiagramEdge} can define their own change events and and make listeners aware of them via their
fiore@3 38 * {@code notifyChnage()} method. Listeners (defined outside this package as well) can then identify such changes using this string.
fiore@3 39 * @param source the source of the change that triggered this event
fiore@3 40 */
fiore@3 41 public ElementChangedEvent( DiagramElement element, Object args, String changeType, Object source) {
fiore@0 42 super(source);
fiore@0 43 this.changeType = changeType;
fiore@0 44 this.element = element;
fiore@3 45 this.arguments = args;
fiore@0 46 }
fiore@0 47
fiore@0 48 /**
fiore@0 49 * A String representing the change type. Subclasses of DiagramNode and DiagramEdge
fiore@0 50 * can throw their own events by passing as argument a String that describes the change.
fiore@0 51 * Such events will have no effect in the model but will be fired to all the registered ChangeEventListener.
fiore@0 52 *
fiore@0 53 * @return a String describing the change type
fiore@0 54 */
fiore@0 55 public String getChangeType(){
fiore@0 56 return changeType;
fiore@0 57 }
fiore@0 58
fiore@0 59 /**
fiore@0 60 * Returns the DiagramElement that has been affected by this change
fiore@0 61 * @return the DiagramElement that has been affected by this change
fiore@0 62 */
fiore@0 63 public DiagramElement getDiagramElement(){
fiore@0 64 return element;
fiore@0 65 }
fiore@0 66
fiore@3 67 /**
fiore@3 68 * Returns the arguments of the change if the the change type has any
fiore@3 69 *
fiore@3 70 * @return an object representing the arguments or null
fiore@3 71 */
fiore@3 72 public Object getArguments(){
fiore@3 73 return arguments;
fiore@3 74 }
fiore@3 75
fiore@0 76 private String changeType;
fiore@3 77 private DiagramElement element;
fiore@3 78 private Object arguments;
fiore@3 79
fiore@3 80 /**
fiore@3 81 * This class is returned by {@link ElementChangedEvent#getArguments()} when a node property is
fiore@3 82 * changed. It holds the informations about the property type and the property index, so that
fiore@3 83 * listeners can retrieve the property when handling the event.
fiore@3 84 *
fiore@3 85 */
fiore@3 86 public static class PropertyChangeArgs {
fiore@3 87 public PropertyChangeArgs(String type, int index, String oldValue){
fiore@3 88 this.type = type;
fiore@3 89 this.index = index;
fiore@3 90 this.oldValue = oldValue;
fiore@3 91 }
fiore@3 92
fiore@3 93 public String getPropertyType(){
fiore@3 94 return type;
fiore@3 95 }
fiore@3 96
fiore@3 97 public int getPropertyIndex(){
fiore@3 98 return index;
fiore@3 99 }
fiore@3 100
fiore@3 101 public String getOldValue(){
fiore@3 102 return oldValue;
fiore@3 103 }
fiore@3 104
fiore@3 105 private String type;
fiore@3 106 private String oldValue;
fiore@3 107 private int index;
fiore@3 108 }
fiore@0 109 }