Java Code Examples for java.awt.geom.Point2D#clone()

The following examples show how to use java.awt.geom.Point2D#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelayoutFunctionGraphJob.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private List<ArticulationTransitionPoints> getArticulationTransitionPointsWhenStartingWithMorePoints(
		List<Point2D> currentArticulations, List<Point2D> newArticulations,
		Map<V, Point2D> destinationLocations, E edge) {

	List<ArticulationTransitionPoints> transitionPoints = new ArrayList<>();

	for (int i = 0; i < currentArticulations.size(); i++) {

		Point2D startPoint = currentArticulations.get(i);
		Point2D endPoint = (Point2D) startPoint.clone();
		if (i < newArticulations.size()) {
			// prefer the new articulations, while we have some
			endPoint = newArticulations.get(i);
		}

		transitionPoints.add(new ArticulationTransitionPoints(startPoint, endPoint));
	}

	return transitionPoints;
}
 
Example 2
Source File: GroupVertexFunctionGraphJob.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private List<ArticulationTransitionPoints> getArticulationTransitionPointsWhenStartingWithMorePoints(
		List<Point2D> currentArticulations, List<Point2D> newArticulations,
		Map<FGVertex, Point2D> destinationLocations, FGEdge edge) {
	List<ArticulationTransitionPoints> transitionPoints = new ArrayList<>();

	for (int i = 0; i < currentArticulations.size(); i++) {
		Point2D startPoint = currentArticulations.get(i);
		Point2D endPoint = (Point2D) startPoint.clone();
		if (i < newArticulations.size()) {
			// prefer the new articulations, while we have some
			endPoint = newArticulations.get(i);
		}
		else {
			// less articulations in the new layout--map to the destination point of the
			// destination vertex
			FGVertex destinationVertex = edge.getEnd();
			TransitionPoints destionationTranstionPoint =
				getTransitionPoint(vertexLocations, destinationLocations, destinationVertex);
			endPoint = destionationTranstionPoint.destinationPoint;
		}

		transitionPoints.add(new ArticulationTransitionPoints(startPoint, endPoint));
	}

	return transitionPoints;
}
 
Example 3
Source File: RelayoutFunctionGraphJob.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private List<ArticulationTransitionPoints> getArticulationTransitionPointsWhenStartingWithLessPoints(
		List<Point2D> currentArticulations, List<Point2D> newArticulations,
		Map<V, Point2D> destinationLocations, E edge) {

	List<ArticulationTransitionPoints> transitionPoints = new ArrayList<>();

	// 
	// We will have to add articulations to the current edge now so that we can
	// animate their creation.
	//
	List<Point2D> newStartArticulationsPoints = new ArrayList<>();

	// default to start vertex so to handle the case where we started with no articulations
	Point2D lastValidStartPoint = toLocation(edge.getStart());
	for (int i = 0; i < newArticulations.size(); i++) {
		Point2D endPoint = newArticulations.get(i);

		Point2D startPoint = (Point2D) lastValidStartPoint.clone();
		if (i < currentArticulations.size()) {
			// prefer the new articulations, while we have some
			startPoint = currentArticulations.get(i);
			lastValidStartPoint = startPoint;
		}

		transitionPoints.add(new ArticulationTransitionPoints(startPoint, endPoint));
		newStartArticulationsPoints.add(startPoint);
	}

	edge.setArticulationPoints(newStartArticulationsPoints);

	return transitionPoints;
}
 
Example 4
Source File: SplineControlPanel.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Point2D evaluate(Point2D v0, Point2D v1,
        float fraction) {
    Point2D value = (Point2D)v0.clone();
    if (v0 != v1) {
        double x = value.getX();
        x += (v1.getX() - v0.getX()) * fraction;
        double y = value.getY();
        y += (v1.getY() - v0.getY()) * fraction;
        value.setLocation(x, y);
    } else {
        value.setLocation(v0.getX(), v0.getY());
    }
    return value;
}
 
Example 5
Source File: UngroupVertexFunctionGraphJob.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private TransitionPoints createTransitionPoint(Map<FGVertex, Point2D> destinationLocations,
		FGVertex vertex) {
	Point2D currentPoint = toLocation(vertex);
	Point2D startPoint = (Point2D) currentPoint.clone();

	Point2D endPoint = destinationLocations.get(vertex);
	if (endPoint == null) {
		// this can happen when the vertex is the group vertex being removed; just 
		// use the start point
		endPoint = startPoint;
	}

	Point2D destinationPoint = (Point2D) endPoint.clone();
	return new TransitionPoints(startPoint, destinationPoint);
}
 
Example 6
Source File: UngroupVertexFunctionGraphJob.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private List<ArticulationTransitionPoints> getArticulationTransitionPointsWhenStartingWithLessPoints(
		List<Point2D> currentArticulations, List<Point2D> newArticulations,
		Map<FGVertex, Point2D> destinationLocations, FGEdge edge) {

	List<ArticulationTransitionPoints> transitionPoints = new ArrayList<>();

	// 
	// In this case we will have to add articulations to the current edge now so that we can
	// animate their creation.
	//
	List<Point2D> newStartArticulationsPoints = new ArrayList<>();

	// default to start vertex so to handle the case where we started with no articulations
	Point2D lastValidStartPoint = toLocation(edge.getStart());
	for (int i = 0; i < newArticulations.size(); i++) {
		Point2D endPoint = newArticulations.get(i);

		Point2D startPoint = (Point2D) lastValidStartPoint.clone();
		if (i < currentArticulations.size()) {
			// prefer the new articulations, while we have some
			startPoint = currentArticulations.get(i);
			lastValidStartPoint = startPoint;
		}

		transitionPoints.add(new ArticulationTransitionPoints(startPoint, endPoint));
		newStartArticulationsPoints.add(startPoint);
	}

	edge.setArticulationPoints(newStartArticulationsPoints);

	return transitionPoints;
}
 
Example 7
Source File: UngroupVertexFunctionGraphJob.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private List<ArticulationTransitionPoints> getArticulationTransitionPointsWhenStartingWithMorePoints(
		List<Point2D> currentArticulations, List<Point2D> newArticulations,
		Map<FGVertex, Point2D> destinationLocations, FGEdge edge) {

	List<ArticulationTransitionPoints> transitionPoints = new ArrayList<>();

	for (int i = 0; i < currentArticulations.size(); i++) {

		Point2D startPoint = currentArticulations.get(i);
		Point2D endPoint = (Point2D) startPoint.clone();
		if (i < newArticulations.size()) {
			// prefer the new articulations, while we have some
			endPoint = newArticulations.get(i);
		}
		else {
			// less articulations in the new layout--map to the destination point of the
			// destination vertex
			FGVertex destinationVertex = edge.getEnd();
			TransitionPoints destionationTranstionPoint =
				getTransitionPoint(vertexLocations, destinationLocations, destinationVertex);
			endPoint = destionationTranstionPoint.destinationPoint;
		}

		transitionPoints.add(new ArticulationTransitionPoints(startPoint, endPoint));
	}

	return transitionPoints;
}
 
Example 8
Source File: MergeVertexFunctionGraphJob.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void initializeVertexLocations() {
	// 
	// We will create the new locations for the new parent and child vertices.  There will
	// be the initial (start) location for each one and the destination location for each
	// one.  This allows us to show a transition from the start to the destination point.
	//		

	// Update the new parent node to compensate for its new size.  This code effectively 
	// moves the new vertex up to account for the fact that its overall height has been 
	// reduced.  This is necessary to prevent the vertex from moving down, as the location of
	// a vertex is based upon its center point.
	Rectangle originalBounds = parentVertex.getBounds();
	Rectangle newBounds = mergedVertex.getBounds();
	int dy = (newBounds.height - originalBounds.height) >> 1;

	Point2D parentLocation = graphLayout.apply(parentVertex);
	Point2D mergedLocation = (Point2D) parentLocation.clone();
	mergedLocation.setLocation(parentLocation.getX(), parentLocation.getY() + dy);

	parentStart = parentLocation;
	parentDestination = parentStart; // this vertex doesn't move
	childStart = graphLayout.apply(childVertex);
	childDestination = parentDestination; // they will end up together
	mergedDestination = mergedLocation;

	Point2D oldLocationProperty = parentVertex.getLocation();
	mergedVertex.setLocation(oldLocationProperty);
	graphLayout.setLocation(mergedVertex, mergedDestination); // tell the graph the new location

	// note: due to the caching nature of some layouts, if we don't reset this, then 
	// some of our GUI calculations will be incorrect (like when we try to fit the 
	// satellite in it's window).  So, we always have to clear the cache when we set locations
	clearLocationCache();
}
 
Example 9
Source File: SplitVertexFunctionGraphJob.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void initializeVertexLocations() {
	// 
	// We will create the new locations for the new parent and child vertices.  There will
	// be the initial (start) location for each one and the destination location for each
	// one.  This allows us to show a transition from the start to the destination point.
	//
	Point2D oldLocation = graphLayout.apply(toSplitVertex);
	Point2D oldLocationProperty = toSplitVertex.getLocation();
	Point2D parentLocation = (Point2D) oldLocation.clone();
	Point2D parentLocationProperty = (Point2D) oldLocationProperty.clone();

	// Update the new parent node to compensate for its new size.  This code effectively 
	// moves the new vertex up to account for the fact that its overall height has been 
	// reduced.  This is necessary to prevent the vertex from moving down, as the location of
	// a vertex is based upon its center point.
	Rectangle originalBounds = toSplitVertex.getBounds();
	Rectangle newBounds = parentVertex.getBounds();
	int dy = (newBounds.height - originalBounds.height) >> 1;
	parentLocation.setLocation(parentLocation.getX(), parentLocation.getY() + dy);

	parentStart = parentLocation;
	parentDestination = parentStart; // this vertex doesn't move
	childStart = parentStart; // this vertex starts at the same place as the parent

	parentVertex.setLocation(parentLocationProperty);
	graphLayout.setLocation(parentVertex, parentLocation); // tell the graph the new location

	Point2D childStartLocation = (Point2D) parentLocation.clone();
	childVertex.setLocation(oldLocationProperty);
	graphLayout.setLocation(childVertex, childStartLocation); // tell the graph the new location

	// Move the new child vertex down and add space between it and its parent.
	Rectangle parentBounds = parentVertex.getBounds();
	double childY = childStartLocation.getY() + parentBounds.height +
		GraphViewerUtils.EXTRA_LAYOUT_ROW_SPACING;
	childDestination = new Point2D.Double(childStartLocation.getX(), childY);

	// note: due to the caching nature of some layouts, if we don't reset this, then 
	// some of our GUI calculations will be incorrect (like when we try to fit the 
	// satellite in it's window).  So, we always have to clear the cache when we set locations
	clearLocationCache();
}
 
Example 10
Source File: AbstractFilter.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    return (Point2D) srcPt.clone();
}
 
Example 11
Source File: AdvancedResizeOp.java    From scrimage with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public final Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
  return (Point2D) srcPt.clone();
}
 
Example 12
Source File: AbstractFilter.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    return (Point2D) srcPt.clone();
}
 
Example 13
Source File: AbstractImageFilter.java    From open-ig with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
	return (Point2D)srcPt.clone();
}
 
Example 14
Source File: AbstractFilter.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    return (Point2D) srcPt.clone();
}
 
Example 15
Source File: AbstractGraphTransitionJob.java    From ghidra with Apache License 2.0 4 votes vote down vote up
public ArticulationTransitionPoints(Point2D currentEdgePoint, Point2D destinationPoint) {
	super((Point2D) currentEdgePoint.clone(), destinationPoint);
	this.pointToUpdate = currentEdgePoint;
}
 
Example 16
Source File: AbstractFilter.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    return (Point2D) srcPt.clone();
}
 
Example 17
Source File: AbstractFilter.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    return (Point2D) srcPt.clone();
}
 
Example 18
Source File: AbstractFilter.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    return (Point2D) srcPt.clone();
}
 
Example 19
Source File: AbstractFilter.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    return (Point2D) srcPt.clone();
}
 
Example 20
Source File: AbstractFilter.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    return (Point2D) srcPt.clone();
}