📄 nettel.java
字号:
public boolean getIconVisible() { return iconVisible; } public void setIconVisible(boolean visible) { iconVisible = visible; } public boolean isVisible() { return isVisible; } public void setVisible(boolean visible) { // Sett visible-status for denne nettel isVisible = visible; } public void transform() { if (clickId != 0) { setBoksid(clickId); setKat(clickKat); } } public void setXY(int InX, int InY) { int canvasX = com.getNet().getMinimumSize().width; int canvasY = com.getNet().getMinimumSize().height; if (canvasY == 0 && InY < canvasTopSpaceY) { y = canvasTopSpaceY; } else if (canvasX > 0) { if (InX > 0 && InX < canvasX-sizeX) { x = InX; } else { if (InX <= 0) { x = 0; } else { x = canvasX-sizeX-1; } } if (InY > canvasTopSpaceY && InY < canvasY-sizeY) { y = InY; } else { if (InY <= canvasTopSpaceY) { y = canvasTopSpaceY; } else { y = canvasY-sizeY-1; } } } else { x = InX; y = InY; } nettelIcon.setXY(x, y); } public void locationSet() { locationSet = true; } public boolean getLocationSet() { return locationSet; } public int getX() { return x; } public int getY() { return y; } public int getSizeX() { return sizeX; } public int getSizeY() { return nettelIcon.getSizeY(); } public void setMouseOver(boolean InMouseOver, int InMouseOverX, int InMouseOverY) { mouseOver = InMouseOver; mouseOverX = InMouseOverX; mouseOverY = InMouseOverY; if (mouseOver) { if (nc != null) { if (drawPopup) { setDrawPopup(false); } nc.end(); } nc = new NettelAction(this); nc.start(); } else { if (drawPopup) { setDrawPopup(false); } } } public boolean getMouseOver() { return mouseOver; } public void disablePopup() { if (nc != null) { nc.end(); } if (getDrawPopup()) { setDrawPopup(false); } } public void setDrawPopup(boolean drawPopup) { this.drawPopup = drawPopup; if (drawPopup && !popupUpToDate) { updatePopup(); } if (mouseOverLink == -1) { // Muspekeren er over selve boksen if (drawPopup) { com.d(" Popup over boks drawn", 6); addPopup(desc); desc.show(mouseOverX, mouseOverY, graph); } else { com.d(" Popup over boks hidden", 6); //desc.hide(); hideAllPopups(); } } else { // Musen er over en link Link l = (Link)link.elementAt(mouseOverLink); if (drawPopup) { com.d(" Popup over link drawn", 6); PopupMessage pm = l.showPopup(mouseOverX, mouseOverY, graph, com); if (pm != null) addPopup(pm); } else { com.d(" Popup over link hidden", 6); //l.hidePopup(); hideAllPopups(); } } } // Vi ønsker kun at en popup skal vises samtidig, så når en ny popup tas evt. gamle bort private static Vector popupList = new Vector(); private static void addPopup(PopupMessage pm) { popupList.addElement(pm); } private static void hideAllPopups() { for (int i=0; i < popupList.size(); i++) { PopupMessage pm = (PopupMessage)popupList.elementAt(i); pm.hide(); } popupList.removeAllElements(); } public boolean getDrawPopup() { return drawPopup; } public void setDrawVlan(boolean InDrawVlan) { drawVlan = InDrawVlan; } public void setSelected(boolean InSelected) { setSelected = InSelected; if (setSelected) { // må finne size på canavas Dimension d = com.getNet().getMinimumSize(); int canvasX = d.width; int canvasY = d.height; int x = (canvasX - sizeX) / 2; int y = (canvasY - sizeY) / 2; setXY(x, y); } } public Link addLink(Nettel n, int linkId, double capacity, double last, String ifName) { if (groupMember) { if (n.getGroup() == group) { com.d(" " + getName() + " er i gruppe med " + n.getName(), 6); capacity = 0; } } double lastPst; if (capacity == 0 || last < 0) { lastPst = -1; } else { lastPst = (last*8) / (capacity*1000000) * 100; } Link l = new Link(this, n, linkId, capacity, lastPst, ifName); linkNettel.addElement(n); link.addElement(l); return l; } public Link getLinkTo(Nettel n) { for (int i=0; i < link.size(); i++) { Link l = (Link)link.elementAt(i); if (l.getNettelTo().equals(n)) return l; } // Ingen link til n funnet return null; } public void recalcLink(boolean b, Nettel n) { for (int i = 0; i < link.size(); i++) { ((Link)link.elementAt(i)).recalc(); if (b) { ((Nettel)linkNettel.elementAt(i)).recalcLink(false, this); } else if ( ((Nettel)linkNettel.elementAt(i)).equals(n) ) { ((Nettel)linkNettel.elementAt(i)).recalcLink(false, n); } } } public void recalcLink() { for (int i = 0; i < link.size(); i++) { Link l = (Link)link.elementAt(i); l.recalc(); l.getLinkOtherWay().recalc(); } } public void resetLink() { linkNettel.removeAllElements(); link.removeAllElements(); popupUpToDate = false; } public void resetLast() { lastX = 0; lastY = 0; } public void setClicked(boolean b) { click = b; setMove = b; } public void setMove(int moveX, int moveY) { setMove(moveX, moveY, true); } public void setMove(int moveX, int moveY, boolean refresh) { if (setMove) { lastX = moveX - x; lastY = moveY - y; setMove = false; } int oldX = x; int oldY = y; int x = moveX-lastX; int y = moveY-lastY; setXY(x, y); recalcLink(true, this); if (refresh) { com.getNet().repaint(); } } public boolean contains(int x, int y) { if (!isVisible || !iconVisible) return false; if (nettelIcon.contains(x, y) ) { mouseOverLink = -1; return true; } for (int i = 0; i < link.size(); i++) { if ( ((Link)link.elementAt(i)).contains(x, y) ) { mouseOverLink = i; return true; } } return false; } // Opplyser om punktet (x,y) er innenfor selve boksen public boolean boksContains(int x, int y) { if (!isVisible || !iconVisible) return false; return nettelIcon.contains(x, y); } public boolean containsNettel(int x, int y) { return nettelIcon.contains(x, y); } public boolean containsLink(int x, int y) { for (int i = 0; i < link.size(); i++) { if ( ((Link)link.elementAt(i)).contains(x, y) ) { return true; } } return false; } public Link getLink(int x, int y) { for (int i = 0; i < link.size(); i++) { if ( ((Link)link.elementAt(i)).contains(x, y) ) { return (Link)link.elementAt(i); } } return null; } private void updatePopup() { desc = new PopupMessage(com.getNet(), popupFont); if (descText != null) { desc.addMessage(descText); } // Så oppdaterer vi alle linker for (int i=0; i < link.size(); i++) { Link l = (Link)link.elementAt(i); com.d(" Calling updatePopup on link", 7); l.updatePopup(com.getNet(), popupFont); } popupUpToDate = true; } public String processText(String text, String[] data) { descText = Input.processText(text, data, keywords); return descText; } public String toString() { return getName(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -