예제 #1
0
private void ShowStatus (int x, int y)
    {
        String s = "";
        CGNode node = null;

        if (x >= 0 && y >= 0) {
            try {
                CanvasObject co = super.Find (x, y);
                if (co instanceof CGNode) {
                    node = (CGNode)co;
                }
            } catch (NoSuchElementException ex) {}

            if (node == null) {
                if (topnode == null)
                    s = "Button1: create";
            } else {
		s = "Button1: drag";
                if (node.IsConcept()) {
		    if (node.GetInst() != null)
			s += ", Shift-Button1: edit";
		    if (node == topnode)
			s += ", Shift-Ctrl-Button1: remove";
                    if (menumap.containsKey (node.GetType (true)))
                        s += ", Button3: menu";
                } else {
                    s += ", Shift-Ctrl-Button1: remove";
                }
            }
        }
	frame.status.setStatus (s);
    }
예제 #2
0
private void Pick (MouseEvent ev)
    {
	if (state != stateIdle)
	    return;

	CGNode node = null;
	try {
	    CanvasObject co = super.Find (ev.getX(), ev.getY());
	    if (co instanceof CGNode) {
		node = (CGNode)co;
	    }
	} catch (NoSuchElementException ex) {}

        if (node != null && node.IsConcept() &&
            (ev.getModifiers() & Event.META_MASK) != 0) {
            // template menu

            MenuPopup (ev, node);
        } else {
            switch (ev.getModifiers() & (Event.SHIFT_MASK | Event.CTRL_MASK)) {
            case Event.SHIFT_MASK:
                // edit
                if (node != null) {
		    String s = node.GetInst();
		    if (s != null) {
			curnode = node;
			Edit (s);
		    }
                }
                break;

            case Event.CTRL_MASK:
                // drag
                if (node != null) {
                    state = stateDrag;
                    ToTop (node);
                    curnode = node;
                    dragx = ev.getX();
                    dragy = ev.getY();
                }
                break;

            case Event.SHIFT_MASK|Event.CTRL_MASK:
                // delete subtree
                if (node != null) {
		    // ZZZ only allowed for relations or topnode
		    if (node.IsConcept() && node != topnode)
			break;
                    CGNode parent = node.GetParent ();
                    if (parent == null || parent.IsConcept() ||
                        parent.NumChilds() > 1) {
                        
                        AutoUpdateOff ();
                        if (parent != null) {
                            parent.DelChild (node);
                            Remove (node.GetParentArrow());
                        }
                        RemoveFromCanvas (node);
                        AutoUpdateOn ();
                    }
                    if (node == topnode)
                        topnode = null;
                    NotifyViewers();
                }
                break;

            default:
                if (node == null && topnode == null) {
		    // create topnode
                    topnode = new CGNode (ev.getX(), ev.getY(),
					  "OPERATION:deposit",
                                          getFontMetrics (getFont()),
                                          true);
                    Add (topnode);
                    NotifyViewers ();
                } else if (node != null) {
		    // ZZZ drag
                    state = stateDrag;
                    ToTop (node);
                    curnode = node;
                    dragx = ev.getX();
                    dragy = ev.getY();
		}
		/*
		 * ZZZ creating subnodes not allowed
		else if (node != null && topnode != null) {
                    state = stateCreate;
                    curnode = node;
                    
                    Rectangle pos = node.Bbox();
                    curarrow = new CGArrow (pos.x+pos.width-1,
                                            pos.y+pos.height/2,
                                            ev.x, ev.y);
                    Add (curarrow);
                }
		*/
                break;
            }
        }
    }