001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.soa.mappercore;
021:
022: import javax.swing.JLabel;
023: import javax.swing.tree.TreePath;
024: import org.netbeans.modules.soa.mappercore.model.GraphItem;
025: import org.netbeans.modules.soa.mappercore.model.Link;
026: import org.netbeans.modules.soa.mappercore.model.Vertex;
027: import org.netbeans.modules.soa.mappercore.model.VertexItem;
028: import org.netbeans.modules.soa.mappercore.utils.Utils;
029:
030: /**
031: *
032: * @author anjeleevich
033: */
034: public class LinkToolCanvasRendererContext implements
035: CanvasRendererContext {
036:
037: private LinkTool linkTool;
038: private CanvasRendererContext defaultContext;
039:
040: public LinkToolCanvasRendererContext(LinkTool linkTool) {
041: this .defaultContext = linkTool.getCanvas()
042: .getDefaultRendererContext();
043: this .linkTool = linkTool;
044: }
045:
046: private CanvasRendererContext getDefaultRendererContext() {
047: return defaultContext;
048: }
049:
050: public JLabel getTextRenderer() {
051: return defaultContext.getTextRenderer();
052: }
053:
054: public boolean isSelected(TreePath treePath) {
055: return defaultContext.isSelected(treePath);
056: }
057:
058: public boolean isSelected(TreePath treePath, GraphItem graphItem) {
059: return defaultContext.isSelected(treePath, graphItem);
060: }
061:
062: public boolean paintVertex(TreePath treePath, Vertex vertex) {
063: return true;
064: }
065:
066: public boolean paintLink(TreePath treePath, Link link) {
067: if (link != linkTool.getOldLink())
068: return true;
069: return !Utils.equal(treePath, linkTool.getOldTreePath());
070: }
071:
072: public boolean paintVertexItemPin(TreePath treePath,
073: VertexItem vertexItem) {
074: return linkTool.getActivePins().contains(treePath, vertexItem)
075: && linkTool.getTargetPin() != vertexItem;
076: }
077:
078: public boolean paintVertexPin(TreePath treePath, Vertex vertex) {
079: return linkTool.getActivePins().contains(treePath, vertex)
080: && linkTool.getSourcePin() != vertex;
081: }
082:
083: public int getStep() {
084: return defaultContext.getStep();
085: }
086:
087: public Mapper getMapper() {
088: return defaultContext.getMapper();
089: }
090:
091: public Canvas getCanvas() {
092: return defaultContext.getCanvas();
093: }
094:
095: public LeftTree getLeftTree() {
096: return defaultContext.getLeftTree();
097: }
098:
099: public RightTree getRightTree() {
100: return defaultContext.getRightTree();
101: }
102:
103: public int getCanvasVisibleMinX() {
104: return defaultContext.getCanvasVisibleMinX();
105: }
106:
107: public int getCanvasVisibleMaxX() {
108: return defaultContext.getCanvasVisibleMaxX();
109: }
110:
111: public int getGraphX() {
112: return defaultContext.getGraphX();
113: }
114:
115: public int getCanvasVisibleCenterX() {
116: return defaultContext.getCanvasVisibleCenterX();
117: }
118: }
|