📄 arcproto.java
字号:
/** * Method to tell if instances of this ArcProto are invisible. * When all of its layers have been made invisible, the node is flagged to be invisible. * @return true if instances of this ArcProto are invisible. */ public boolean isArcInvisible() { return (userBits & AINVISIBLE) != 0; } /** * Method to allow instances of this ArcProto not to be considered in * tech palette for the calculation of the largest icon. * Valid for menu display */ public void setSkipSizeInPalette() { userBits |= SKIPSIZEINPALETTE; } /** * Method to tell if instaces of this ArcProto are special (don't appear in menu). * Valid for menu display */ public boolean isSkipSizeInPalette() { return (userBits & SKIPSIZEINPALETTE) != 0; } /** * Method to set this ArcProto so that instances of it can wipe nodes. * For display efficiency reasons, pins that have arcs connected to them should not bother being drawn. * Those arc prototypes that can erase their connecting pins have this state set, * and when instances of these arcs connect to the pins, those pins stop being drawn. * It is necessary for the pin node prototype to enable wiping (with setArcsWipe). * A NodeInst that becomes wiped out has "setWiped" called. */ public void setWipable() { userBits |= CANWIPE; } /** * Method to set this ArcProto so that instances of it cannot wipe nodes. * For display efficiency reasons, pins that have arcs connected to them should not bother being drawn. * Those arc prototypes that can erase their connecting pins have this state set, * and when instances of these arcs connect to the pins, those pins stop being drawn. * It is necessary for the pin node prototype to enable wiping (with setArcsWipe). * A NodeInst that becomes wiped out has "setWiped" called. */ public void clearWipable() { userBits &= ~CANWIPE; } /** * Method to tell if instances of this ArcProto can wipe nodes. * For display efficiency reasons, pins that have arcs connected to them should not bother being drawn. * Those arc prototypes that can erase their connecting pins have this state set, * and when instances of these arcs connect to the pins, those pins stop being drawn. * It is necessary for the pin node prototype to enable wiping (with setArcsWipe). * A NodeInst that becomes wiped out has "setWiped" called. * @return true if instances of this ArcProto can wipe nodes. */ public boolean isWipable() { return (userBits & CANWIPE) != 0; } /** * Method to set this ArcProto so that instances of it can curve. * Since arc curvature is complex to draw, arcs with this capability * must be marked this way. * A curved arc has the variable "arc_radius" on it with a curvature factor. */ public void setCurvable() { userBits |= CANCURVE; } /** * Method to set this ArcProto so that instances of it cannot curve. * Since arc curvature is complex to draw, arcs with this capability * must be marked this way. * A curved arc has the variable "arc_radius" on it with a curvature factor. */ public void clearCurvable() { userBits &= ~CANCURVE; } /** * Method to tell if instances of this ArcProto can curve. * Since arc curvature is complex to draw, arcs with this capability * must be marked this way. * A curved arc has the variable "arc_radius" on it with a curvature factor. * @return true if instances of this ArcProto can curve. */ public boolean isCurvable() { return (userBits & CANCURVE) != 0; } /** * Method to set this ArcProto so that instances of it can be selected by their edge. * Artwork primitives that are not filled-in or are outlines want edge-selection, instead * of allowing a click anywhere in the bounding box to work. */ public void setEdgeSelect() { userBits |= AEDGESELECT; } /** * Method to set this ArcProto so that instances of it cannot be selected by their edge. * Artwork primitives that are not filled-in or are outlines want edge-selection, instead * of allowing a click anywhere in the bounding box to work. */ public void clearEdgeSelect() { userBits &= ~AEDGESELECT; } /** * Method to tell if instances of this ArcProto can be selected by their edge. * Artwork primitives that are not filled-in or are outlines want edge-selection, instead * of allowing a click anywhere in the bounding box to work. * @return true if instances of this ArcProto can be selected by their edge. */ public boolean isEdgeSelect() { return (userBits & AEDGESELECT) != 0; } /** * Method to allow instances of this ArcProto to be special in menu. * Valid for menu display */ public void setSpecialArc() { userBits |= ARCSPECIAL; } /** * Method to tell if instaces of this ArcProto are special (don't appear in menu). * Valid for menu display */ public boolean isSpecialArc() { return (userBits & ARCSPECIAL) != 0; } /** * Method to get default ArcInst flags with this portoType. */ public int getDefaultConstraints() { int flags = ImmutableArcInst.DEFAULT_FLAGS; flags = ImmutableArcInst.RIGID.set(flags, isRigid()); flags = ImmutableArcInst.FIXED_ANGLE.set(flags, isFixedAngle()); flags = ImmutableArcInst.SLIDABLE.set(flags, isSlidable()); flags = ImmutableArcInst.HEAD_EXTENDED.set(flags, isExtended()); flags = ImmutableArcInst.TAIL_EXTENDED.set(flags, isExtended()); flags = ImmutableArcInst.HEAD_ARROWED.set(flags, isDirectional()); flags = ImmutableArcInst.BODY_ARROWED.set(flags, isDirectional()); return flags; } /** * Method to return the function of this ArcProto. * The Function is a technology-independent description of the behavior of this ArcProto. * @return function the function of this ArcProto. */ public ArcProto.Function getFunction() { return function; } /** * Method to set the factory-default angle of this ArcProto. * This is only called from ArcProto during construction. * @param angle the factory-default angle of this ArcProto. */ public void setFactoryAngleIncrement(int angle) { Pref pref = Pref.makeIntPref("DefaultAngleFor" + getName() + "IN" + tech.getTechName(), User.getUserTool().prefs, angle); defaultAnglePrefs.put(this, pref); } /** * Method to set the angle increment on this ArcProto. * The angle increment is the granularity on placement angle for instances * of this ArcProto. It is in degrees. * For example, a value of 90 requests that instances run at 0, 90, 180, or 270 degrees. * A value of 0 allows arcs to be created at any angle. * @param angle the angle increment on this ArcProto. */ public void setAngleIncrement(int angle) { Pref pref = defaultAnglePrefs.get(this); if (pref == null) return; pref.setInt(angle); } /** * Method to get the angle increment on this ArcProto. * The angle increment is the granularity on placement angle for instances * of this ArcProto. It is in degrees. * For example, a value of 90 requests that instances run at 0, 90, 180, or 270 degrees. * A value of 0 allows arcs to be created at any angle. * @return the angle increment on this ArcProto. */ public int getAngleIncrement() { Pref pref = defaultAnglePrefs.get(this); if (pref == null) return 90; return pref.getInt(); } /** * Method to get the default angle increment on this ArcProto. * The angle increment is the granularity on placement angle for instances * of this ArcProto. It is in degrees. * For example, a value of 90 requests that instances run at 0, 90, 180, or 270 degrees. * A value of 0 allows arcs to be created at any angle. * @return the default angle increment on this ArcProto. */ public int getFactoryAngleIncrement() { Pref pref = defaultAnglePrefs.get(this); if (pref == null) return 90; return pref.getIntFactoryValue(); } HashMap<ArcProto,Pref> arcPinPrefs = new HashMap<ArcProto,Pref>(); private Pref getArcPinPref() { Pref pref = arcPinPrefs.get(this); if (pref == null) { pref = Pref.makeStringPref("PinFor" + getName() + "IN" + tech.getTechName(), tech.getTechnologyPreferences(), ""); arcPinPrefs.put(this, pref); } return pref; } /** * Method to set the default pin node to use for this ArcProto. * The pin node is used for making bends in wires. * It must have just 1 port in the center, and be able to connect * to this type of arc. * @param np the default pin node to use for this ArcProto. */ public void setPinProto(PrimitiveNode np) { Pref pref = getArcPinPref(); pref.setString(np.getName()); } /** * Method to find the PrimitiveNode pin corresponding to this ArcProto type. * Users can override the pin to use, and this method returns the user setting. * For example, if this ArcProto is metal-1 then return the Metal-1-pin, * but the user could set it to Metal-1-Metal-2-Contact. * @return the PrimitiveNode pin to use for arc bends. */ public PrimitiveNode findOverridablePinProto() { // see if there is a default on this arc proto Pref pref = getArcPinPref(); String primName = pref.getString(); if (primName != null && primName.length() > 0) { PrimitiveNode np = tech.findNodeProto(primName); if (np != null) return np; } return findPinProto(); } /** * Method to find the PrimitiveNode pin corresponding to this ArcProto type. * For example, if this ArcProto is metal-1 then return the Metal-1-pin. * @return the PrimitiveNode pin to use for arc bends. */ public PrimitiveNode findPinProto() { if (arcPin != null) return arcPin; // search for an appropriate pin Iterator<PrimitiveNode> it = tech.getNodes(); while (it.hasNext()) { PrimitiveNode pn = it.next(); if (pn.isPin()) { PrimitivePort pp = (PrimitivePort) pn.getPorts().next(); if (pp.connectsTo(this)) return pn; } } return null; }// public PrimitiveNode makeWipablePin(String pinName, String portName) {// double defSize = DBMath.round(2*getLambdaBaseExtend() + getLambdaElibWidthOffset());// return makeWipablePin(pinName, portName, defSize);// } public PrimitiveNode makeWipablePin(String pinName, String portName, double defSize, ArcProto ... extraArcs) { double elibSize0 = DBMath.round(defSize*0.5); double elibSize1 = DBMath.round(elibSize0 - 0.5*getLambdaElibWidthOffset()); arcPin = PrimitiveNode.makeArcPin(this, pinName, portName, elibSize0, elibSize1, extraArcs); arcPin.setNotUsed(isNotUsed()); return arcPin; } /** * Method to find the ArcProto with the given name. * This can be prefixed by a Technology name. * @param line the name of the ArcProto. * @return the specified ArcProto, or null if none can be found. */ public static ArcProto findArcProto(String line) { Technology tech = Technology.getCurrent(); int colon = line.indexOf(':'); String withoutPrefix; if (colon == -1) withoutPrefix = line; else { String prefix = line.substring(0, colon); Technology t = Technology.findTechnology(prefix); if (t != null) tech = t; withoutPrefix = line.substring(colon+1); } ArcProto ap = tech.findArcProto(withoutPrefix); if (ap != null) return ap; return null; } /** * Method to return the number of layers that comprise this ArcProto. * @return the number of layers that comprise this ArcProto. */ public int getNumArcLayers() { return layers.length; } /** * Method to return layer that comprises by its index in all layers * @param arcLayerIndex layer index * @return specified layer that comprises this ArcProto. */ public Layer getLayer(int arcLayerIndex) { return layers[arcLayerIndex].getLayer(); } /** * Returns the extend of specified layer that comprise this ArcProto over base arc width in lambda units. * @param arcLayerIndex layer index * @return the extend of specified layer that comprise this ArcProto over base arc width in lambda units. */ public double getLayerLambdaExtend(int arcLayerIndex) { return DBMath.gridToLambda(getLayerGridExtend(arcLayerIndex)); } /** * Returns the extend of specified layer that comprise this ArcProto over base arc width in grid units. * @param arcLayerIndex layer index * @return the extend of specified layer that comprise this ArcProto over base arc width in grid units. */ public int getLayerGridExtend(int arcLayerIndex) { return layers[arcLayerIndex].getGridExtend(); } /** * Returns the Poly.Style of specified layer that comprise this ArcLayer. * @param arcLayerIndex layer index * @return the Poly.Style of specified layer that comprise this ArcLayer. */ public Poly.Type getLayerStyle(int arcLayerIndex) { return layers[arcLayerIndex].getStyle(); } /** * Returns the extend of specified layer that comprise this ArcProto over base arc width in lambda units. * @param layer specified Layer * @return the extend of specified layer that comprise this ArcProto over base arc width in lambda units. * @throws IndexOutOfBoundsException when specified layer diesn't comprise this ArcProto */ public double getLayerLambdaExtend(Layer layer) { return getLayerLambdaExtend(indexOf(layer)); } /** * Returns the extend of specified layer that comprise this ArcProto over base arc width in grid units. * @param layer specified Layer * @return the extend of specified layer that comprise this ArcProto over base arc width in grid units. * @throws IndexOutOfBoundsException when specified layer diesn't comprise this ArcProto */ public long getLayerGridExtend(Layer layer) { return getLayerGridExtend(indexOf(layer)); } /** * Returns the Poly.Style of specified layer that comprise this ArcLayer. * @param layer specified Layer * @return the Poly.Style of specified layer that comprise this ArcLayer. * @throws IndexOutOfBoundsException when specified layer diesn't comprise this ArcProto */ public Poly.Type getLayerStyle(Layer layer) { return getLayerStyle(indexOf(layer)); } /** * Method to return specified layer that comprise this ArcProto. * @param i layer index * @return specified layer that comprise this ArcProto. */ Technology.ArcLayer getArcLayer(int i) { return layers[i]; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -