📄 immutablearcinst.java
字号:
this.nameDescriptor = nameDescriptor; this.tailNodeId = tailNodeId; this.tailPortId = tailPortId; this.tailLocation = tailLocation; this.headNodeId = headNodeId; this.headPortId = headPortId; this.headLocation = headLocation; this.gridExtendOverMin = gridExtendOverMin; this.angle = angle; check(); } /** * Retruns true if this ImmutableArcInst was named by user. * @return true if this ImmutableArcInst was named by user. */ public boolean isUsernamed() { return !name.isTempname(); } /** * Returns extend of this ImmutableArcInst over minimal-width arc of this type in lambda units. * @return extend of this ImmutableArcInst over minimal-width arc of this type in lambda units. */ public double getLambdaExtendOverMin() { return DBMath.gridToLambda(getGridExtendOverMin()); } /** * Returns extend of this ImmutableArcInst over minimal-width arc of this type in grid units. * @return extend of this ImmutableArcInst over minimal-width arc of this type in grid units. */ public long getGridExtendOverMin() { return gridExtendOverMin; } /** * Returns length of this ImmutableArcInst in lambda units. * @return length of this ImmutableArcInst in lambda units. */ public double getLambdaLength() { return tailLocation.lambdaDistance(headLocation); } /** * Returns length of this ImmutableArcInst in grid units. * @return length of this ImmutableArcInst in grid units. */ public double getGridLength() { return tailLocation.gridDistance(headLocation); } /** * Returns true if length of this ImmutableArcInst is zero. * @return true if length of this ImmutableArcInst is zero. */ public boolean isZeroLength() { return tailLocation.equals(headLocation); } /** * Method to return the rotation angle of this ImmutableArcInst. * This is an angle of direction from tailLocation to headLocation. * @return the rotation angle of this ImmutableArcInst (in tenth-degrees). */ public int getAngle() { return angle; } /** * Method to return the opposite rotation angle of this ImmutableArcInst. * This is an angle of direction from headLocation to tailLocation. * @return the opposite rotation angle of this ImmutableArcInst (in tenth-degrees). */ public int getOppositeAngle() { return angle >= 1800 ? angle - 1800 : angle + 1800; } /** * Tests specific flag is set on this ImmutableArcInst. * @param flag flag selector. * @return true if specific flag is set, */ public boolean is(Flag flag) { return (flags & flag.mask) != 0; } /** * Method to tell whether this ImmutableArcInst is rigid. * Rigid arcs cannot change length or the angle of their connection to a NodeInst. * @return true if this ImmutableArcInst is rigid. */ public boolean isRigid() { return (flags & RIGID_MASK) != 0; } /** * Method to tell whether this ImmutableArcInst is fixed-angle. * Fixed-angle arcs cannot change their angle, so if one end moves, * the other may also adjust to keep the arc angle constant. * @return true if this ImmutableArcInst is fixed-angle. */ public boolean isFixedAngle() { return (flags & FIXED_ANGLE_MASK) != 0; } /** * Method to tell whether this ImmutableArcInst is slidable. * Arcs that slide will not move their connected NodeInsts if the arc's end is still within the port area. * Arcs that cannot slide will force their NodeInsts to move by the same amount as the arc. * Rigid arcs cannot slide but nonrigid arcs use this state to make a decision. * @return true if this ImmutableArcInst is slidable. */ public boolean isSlidable() { return (flags & SLIDABLE_MASK) != 0; } /** * Method to tell whether this ArcInst is hard-to-select. * Hard-to-select ArcInsts cannot be selected by clicking on them. * Instead, the "special select" command must be given. * @return true if this ArcInst is hard-to-select. */ public boolean isHardSelect() { return (flags & HARD_SELECT_MASK) != 0; } /****************************** PROPERTIES ******************************/ /** * Method to determine whether this ImmutableArcInst is directional, with an arrow on one end. * Directional arcs have an arrow drawn on them to indicate flow. * It is only for documentation purposes and does not affect the circuit. * @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head. * @return true if that end has a directional arrow on it. */ public boolean isArrowed(int connIndex) { if ((connIndex & ~1) != 0) throw new IllegalArgumentException("Bad end " + connIndex); return ((flags >> connIndex) & TAIL_ARROWED_MASK) != 0; } /** * Method to determine whether this ImmutableArcInst is directional, with an arrow on the tail. * Directional arcs have an arrow drawn on them to indicate flow. * It is only for documentation purposes and does not affect the circuit. * @return true if the arc's tail has a directional arrow on it. */ public boolean isTailArrowed() { return (flags & TAIL_ARROWED_MASK) != 0; } /** * Method to determine whether this ImmutableArcInst is directional, with an arrow on the head. * Directional arcs have an arrow drawn on them to indicate flow. * It is only for documentation purposes and does not affect the circuit. * @return true if the arc's head has a directional arrow on it. */ public boolean isHeadArrowed() { return (flags & HEAD_ARROWED_MASK) != 0; } /** * Method to determine whether this ArcInst is directional, with an arrow line drawn down the center. * Directional arcs have an arrow drawn on them to indicate flow. * It is only for documentation purposes and does not affect the circuit. * The body is typically drawn when one of the ends has an arrow on it, but it may be * drawin without an arrow head in order to continue an attached arc that has an arrow. * @return true if the arc's tail has an arrow line on it. */ public boolean isBodyArrowed() { return (flags & BODY_ARROWED_MASK) != 0; } /** * Method to tell whether an end of ImmutableArcInst has its ends extended. * Extended arcs continue past their endpoint by half of their width. * Most layout arcs want this so that they make clean connections to orthogonal arcs. * @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head. * @return true if that end of this ArcInst iss extended. */ public boolean isExtended(int connIndex) { if ((connIndex & ~1) != 0) throw new IllegalArgumentException("Bad end " + connIndex); return ((flags >> connIndex) & TAIL_EXTENDED_MASK) != 0; } /** * Method to tell whether the tail of this arc is extended. * Extended arcs continue past their endpoint by half of their width. * Most layout arcs want this so that they make clean connections to orthogonal arcs. * @return true if the tail of this arc is extended. */ public boolean isTailExtended() { return (flags & TAIL_EXTENDED_MASK) != 0; } /** * Method to tell whether the head of this arc is extended. * Extended arcs continue past their endpoint by half of their width. * Most layout arcs want this so that they make clean connections to orthogonal arcs. * @return true if the head of this arc is extended. */ public boolean isHeadExtended() { return (flags & HEAD_EXTENDED_MASK) != 0; } /** * Method to tell whether an end of this arc is negated. * Negated arc have a negating bubble on them to indicate negation. * This is only valid in schematics technologies. * @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head. * @return true if set that end of this arc is negated. */ public boolean isNegated(int connIndex) { if ((connIndex & ~1) != 0) throw new IllegalArgumentException("Bad end " + connIndex); return ((flags >> connIndex) & TAIL_NEGATED_MASK) != 0; } /** * Method to tell whether the tail of this arc is negated. * Negated arc have a negating bubble on them to indicate negation. * This is only valid in schematics technologies. * @return true if set the tail of this arc is negated. */ public boolean isTailNegated() { return (flags & TAIL_NEGATED_MASK) != 0; } /** * Method to tell whether the head of this arc is negated. * Negated arc have a negating bubble on them to indicate negation. * This is only valid in schematics technologies. * @return true if set the head of this arc is negated. */ public boolean isHeadNegated() { return (flags & HEAD_NEGATED_MASK) != 0; } /** * Returns true if this ImmutableArcInst is either horizontal or vertical. * @return true if this ImmutableArcInst is either horizontal or vertical. */ public boolean isManhattan() { return (flags & MANHATTAN_MASK) != 0; } private static int updateManhattan(int flags, EPoint headLocation, EPoint tailLocation, int angle) { return isManhattan(headLocation, tailLocation, angle) ? flags | MANHATTAN_MASK : flags & ~MANHATTAN_MASK; } private static boolean isManhattan(EPoint headLocation, EPoint tailLocation, int angle) { if (headLocation.getGridX() == tailLocation.getGridX()) { return headLocation.getGridY() != tailLocation.getGridY() || (angle == 0 || angle == 900 || angle == 1800 || angle == 2700); } else { return tailLocation.getGridY() == headLocation.getGridY(); } } /** * Returns new ImmutableArcInst object. * @param arcId id of this ArcInst in parent. * @param protoId Id of arc prototype. * @param name name of this ImmutableArcInst. * @param nameDescriptor TextDescriptor of name of this ImmutableArcInst. * @param tailNodeId NodeId on tail end of this ImmutableArcInst. * @param tailPortId PortProtoId on tail end of this ImmutableArcInst. * @param tailLocation Location of tail end of this ImmutableArcInst. * @param headNodeId NodeId on head end of this ImmutableArcInst. * @param headPortId PortProtoId on head end of this ImmutableArcInst. * @param headLocation Location of head end of this ImmutableArcInst. * @param gridExtendOverMin the extend of this ImmutableArcInst over minimal-width arc of this type in grid units. * @param angle the angle if this ImmutableArcInst (in tenth-degrees). * @param flags flag bits of this ImmutableNodeInst. * @return new ImmutableArcInst object. * @throws NullPointerException if protoType, name, tailPortId, headPortId, tailLocation, headLocation is null. * @throws IllegalArgumentException if arcId, tailNodeId, headNodeId or name is not valid, or width is bad. */ public static ImmutableArcInst newInstance(int arcId, ArcProtoId protoId, Name name, TextDescriptor nameDescriptor, int tailNodeId, PortProtoId tailPortId, EPoint tailLocation, int headNodeId, PortProtoId headPortId, EPoint headLocation, long gridExtendOverMin, int angle, int flags) { if (arcId < 0) throw new IllegalArgumentException("arcId"); if (protoId == null) throw new NullPointerException("protoId"); if (name == null) throw new NullPointerException("name");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -