📄 displaymanager.java
字号:
/* * Copyright (C) 2005, 2006 * Santiago Carot Nemesio * * This file is part of NetGUI. * * NetGUI is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * NetGUI is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NetGUI; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */import edu.umd.cs.piccolo.*;import edu.umd.cs.piccolo.nodes.*;import edu.umd.cs.piccolox.*;import edu.umd.cs.piccolo.util.*;import edu.umd.cs.piccolox.handles.PBoundsHandle;import java.util.*;public class DisplayManager{ private PCamera camera; private PRoot root; private HashMap hiddenLayers; public DisplayManager (PRoot r, PCamera pc) { root = r; camera = pc; hiddenLayers = new HashMap (); } public void addLayerOnTop(PLayer layer) { if (camera.indexOfLayer(layer) == -1) root.addChild(layer); else camera.removeLayer(layer); camera.addLayer(layer); } public void addLayerAtBottom(PLayer layer) { if (camera.indexOfLayer(layer) == -1) root.addChild(layer); else camera.removeLayer(layer); camera.addLayer(1,layer); } public void downLayer(PLayer layer) { int index = camera.indexOfLayer(layer); if (!(index == -1)) { if (!(index==1)) //No esta en el nivel m醩 profundo { camera.removeLayer(layer); camera.addLayer(index-1,layer); } } } public void upLayer(PLayer layer) { int index = camera.indexOfLayer(layer); if (!(index == -1)) { if (!(index==camera.getLayerCount()-1)) //No esta en el nivel m醩 alto { camera.removeLayer(layer); camera.addLayer(index+1,layer); } } } public void hideLayer(PLayer layer) { int index = camera.indexOfLayer(layer); if (!(index == -1)) //Layer existe { Integer deep = new Integer(index); camera.removeLayer(layer); hiddenLayers.put(layer,deep); } } public void showLayer(PLayer layer) { if (hiddenLayers.containsKey(layer)) { int index = ((Integer)(hiddenLayers.get(layer))).intValue(); camera.addLayer(index, layer); hiddenLayers.remove(layer); } } public void toFrontLayer (PLayer layer) { int index = camera.indexOfLayer(layer); if (!(index == -1)) //Layer existe { if (!(index==camera.getLayerCount()-1)) //No esta en el nivel m醩 alto { camera.removeLayer(layer); camera.addLayer(layer); } } } public void toBottomLayer (PLayer layer) { int index = camera.indexOfLayer(layer); if (!(index == -1)) //Layer existe { if (!(index==1)) //No esta en el nivel m醩 profundo { camera.removeLayer(layer); camera.addLayer(1,layer); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -