Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.java.graph;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.Timer;
import javax.swing.UIManager;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.api.visual.action.ActionFactory;
import org.netbeans.api.visual.action.SelectProvider;
import org.netbeans.api.visual.action.WidgetAction;
import org.netbeans.api.visual.border.BorderFactory;
import org.netbeans.api.visual.layout.LayoutFactory;
import org.netbeans.api.visual.model.ObjectState;
import org.netbeans.api.visual.widget.ImageWidget;
import org.netbeans.api.visual.widget.LabelWidget;
import org.netbeans.api.visual.widget.LevelOfDetailsWidget;
import org.netbeans.api.visual.widget.Scene;
import org.netbeans.api.visual.widget.Widget;
import org.netbeans.api.visual.widget.general.IconNodeWidget;
import org.netbeans.api.visual.widget.general.IconNodeWidget.TextOrientation;
import static org.netbeans.modules.java.graph.Bundle.ACT_FixVersionConflict;
import static org.netbeans.modules.java.graph.Bundle.TIP_MultipleConflict;
import static org.netbeans.modules.java.graph.Bundle.TIP_MultipleWarning;
import static org.netbeans.modules.java.graph.Bundle.TIP_SingleConflict;
import static org.netbeans.modules.java.graph.Bundle.TIP_SingleWarning;
import static org.netbeans.modules.java.graph.DependencyGraphScene.VersionProvider.VERSION_CONFLICT;
import static org.netbeans.modules.java.graph.DependencyGraphScene.VersionProvider.VERSION_NO_CONFLICT;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle.Messages;
import org.openide.util.Parameters;
/**
*
* @author mkleint
*/
class NodeWidget extends Widget implements ActionListener {
static final Color ROOT = new Color(178, 228, 255);
static final Color DIRECTS = new Color(178, 228, 255);
static final Color DIRECTS_CONFLICT = new Color(235, 88, 194);
static final Color DISABLE_HIGHTLIGHT = new Color(255, 255, 194);
static final Color HIGHTLIGHT = new Color(255, 255, 129);
static final Color CONFLICT = new Color(219, 11, 5);
static final Color DISABLE_CONFLICT = EdgeWidget.deriveColor(CONFLICT, 0.7f);
static final Color MANAGED = new Color(30, 255, 150);
static final Color WARNING = new Color(255, 150, 20);
static final Color DISABLE_WARNING = EdgeWidget.deriveColor(WARNING, 0.7f);
private static final int LEFT_TOP = 1;
private static final int LEFT_BOTTOM = 2;
private static final int RIGHT_TOP = 3;
private static final int RIGHT_BOTTOM = 4;
private static final @StaticResource String LOCK_ICON = "org/netbeans/modules/java/graph/resources/lock.png";
private static final @StaticResource String LOCK_BROKEN_ICON = "org/netbeans/modules/java/graph/resources/lock-broken.png";
private static final @StaticResource String BULB_ICON = "org/netbeans/modules/java/graph/resources/bulb.gif";
private static final @StaticResource String BULB_HIGHLIGHT_ICON = "org/netbeans/modules/java/graph/resources/bulb-highlight.gif";
private GraphNode node;
private boolean readable = false;
private boolean isHighlighted = false;
private boolean enlargedFromHover = false;
private Timer hoverTimer;
private Color hoverBorderC;
private IconNodeWidget nodeW;
private LabelWidget versionW;
private Widget contentW;
private ImageWidget lockW, fixHintW;
private int paintState = EdgeWidget.REGULAR;
private Font origFont;
private Color origForeground;
private String tooltipText;
private final WidgetAction fixConflictAction;
private final WidgetAction sceneHoverActionAction;
// for use from FruchtermanReingoldLayout
public double locX, locY, dispX, dispY;
private boolean fixed;
NodeWidget(@NonNull DependencyGraphScene scene, GraphNode node, final Action fixConflictAction, final WidgetAction sceneHoverActionAction) {
super(scene);
Parameters.notNull("node", node);
if(fixConflictAction != null) {
Parameters.notNull("sceneHoverActionAction", sceneHoverActionAction);
}
this.node = node;
this.fixConflictAction = fixConflictAction != null ? ActionFactory.createSelectAction(new SelectProvider() {
@Override public boolean isAimingAllowed(Widget widget, Point localLocation, boolean invertSelection) {
return false;
}
@Override public boolean isSelectionAllowed(Widget widget, Point localLocation, boolean invertSelection) {
return true;
}
@Override
public void select(Widget widget, Point localLocation, boolean invertSelection) {
fixConflictAction.actionPerformed(null);
}
}) : null;
this.sceneHoverActionAction = sceneHoverActionAction;
setLayout(LayoutFactory.createVerticalFlowLayout());
updateTooltip();
initContent(scene, node.getImpl(), scene.getIcon(node));
hoverTimer = new Timer(500, this);
hoverTimer.setRepeats(false);
hoverBorderC = UIManager.getColor("TextPane.selectionBackground");
if (hoverBorderC == null) {
hoverBorderC = Color.GRAY;
}
}
@Messages({"TIP_Text={0} {1}",
"TIP_SingleConflict=Conflict with {0} version required by {1}",
"TIP_SingleWarning=Warning, older version {0} requested by {1}",
"TIP_MultipleConflict=Conflicts with: