/** Forwards a graph event to anyone listening. */ public void forwardGraph(GraphEventObject e) { List l; // GraphEventObject weo = new GraphEventObject(this,e); synchronized (this) { l = (List) ((ArrayList) graphListeners).clone(); } for (int i = 0; i < l.size(); i++) { GraphListener wl = (GraphListener) l.get(i); wl.handleGraph(e); } }
private void removeNonVisibleItems(final int dx) { View child = getChildAt(0); while (child != null && child.getRight() + dx <= 0) { mDisplayOffset += child.getMeasuredWidth(); mRemovedViewQueue.offer(child); removeViewInLayout(child); mLeftViewIndex++; if (mGraphListener != null && child != null) mGraphListener.viewRemoved(child); child = getChildAt(0); } child = getChildAt(getChildCount() - 1); while (child != null && child.getLeft() + dx >= getWidth()) { mRemovedViewQueue.offer(child); removeViewInLayout(child); mRightViewIndex--; if (mGraphListener != null && child != null) mGraphListener.viewRemoved(child); child = getChildAt(getChildCount() - 1); } }
private void fillListLeft(int leftEdge, final int dx) { while (leftEdge + dx > 0 && mLeftViewIndex >= 0) { View child = mAdapter.getView(mLeftViewIndex, mRemovedViewQueue.poll(), this); addAndMeasureChild(child, 0); leftEdge -= child.getMeasuredWidth(); mLeftViewIndex--; mDisplayOffset -= child.getMeasuredWidth(); if (mGraphListener != null && child != null) mGraphListener.viewAdded(child); } }
private void fillListRight(int rightEdge, final int dx) { while (rightEdge + dx < getWidth() && mRightViewIndex < mAdapter.getCount()) { View child = mAdapter.getView(mRightViewIndex, mRemovedViewQueue.poll(), this); addAndMeasureChild(child, -1); rightEdge += child.getMeasuredWidth(); if (mRightViewIndex == mAdapter.getCount() - 1) { mMaxX = mCurrentX + rightEdge - getWidth(); } if (mMaxX < 0) { mMaxX = 0; } mRightViewIndex++; if (mGraphListener != null && child != null) mGraphListener.viewAdded(child); } }
/** Notify listeners (GraphViewer and Layouter) of arc addition to graph model */ public void notifyArcAddtion(Arc anArc) { for (GraphListener observer : observers) { observer.arcAdded(anArc); } }
/** Notify listeners (GraphViewer and Layouter) of node deletion from graph model */ public void notifyNodeDeletion(Node aNode) { for (GraphListener observer : observers) { observer.nodeDeleted(aNode); } }
/** Notify listeners (GraphViewer and Layouter) that graph model is cleared */ public void notifyGraphErased() { for (GraphListener observer : observers) { observer.graphErased(); } }
private void disconnect() { graph.removeGraphListener(graphListener); for (GraphItem item : items()) { graphListener.itemRemoved(graph, item); } }
private void connect() { graph.addGraphListener(graphListener); for (GraphItem item : items()) { graphListener.itemAdded(graph, item); } }
/** * Сообщает подписчикам сообщение * * @param event Сообщение */ protected void fireGraphEvent(GraphEvent<N, E> event) { for (GraphListener listener : listeners) { listener.graphEvent(event); } }