public void paintPatch(Graphics g, Patch p, int x, int y, int cellS) { Color c = Color.BLACK; if (p.color.equals(Color.RED)) { c = Color.ORANGE; } else if (p.smell("food") > 0) { c = new Color((int) (p.smell("food"))); } else { double nestScent = p.smell("nestScent"); double foodScent = p.smell("foodScent"); if (nestScent > maxNestScent) maxNestScent = nestScent; if (foodScent > maxFoodScent) maxFoodScent = foodScent; nestScent /= maxNestScent; foodScent /= maxFoodScent; c = new Color((int) (nestScent * 255), (int) (foodScent * 255), 0); } if (p.getTurtles().length > 0) { if (c.getRed() < 10 && c.getGreen() < 10) c = Color.GRAY.darker().darker(); else c = c.brighter().brighter().brighter(); } g.setColor(c); g.fillRect(x, y, cellS, cellS); }
/** Created by Mostafa Shabani. Date: 4/30/11 Time: 5:51 PM */ public class MrlBurningBuildingLayer extends MrlAreaLayer<Building> { // private static final Color HEATING = new Color(176, 176, 56, 128); // private static final Color BURNING = new Color(204, 122, 50, 128); // private static final Color INFERNO = new Color(160, 52, 52, 128); // private static final Color WATER_DAMAGE = new Color(50, 120, 130, 128); // private static final Color MINOR_DAMAGE = new Color(100, 140, 210, 128); // private static final Color MODERATE_DAMAGE = new Color(100, 70, 190, 128); // private static final Color SEVERE_DAMAGE = new Color(80, 60, 140, 128); // private static final Color BURNT_OUT = new Color(0, 0, 0, 255); private static final Color OUTLINE_COLOUR = Color.GRAY.darker().darker(); private static final Color HEATING_COLOUR = Color.YELLOW; // 1 private static final Color BURNING_COLOUR = Color.ORANGE; // 2 private static final Color INFERNO_COLOUR = Color.RED; // 3 private static final Color WATER_DAMAGE_COLOUR = Color.BLUE; // 4 private static final Color MINOR_DAMAGE_COLOUR = new Color(10, 140, 210, 255); // Color.PINK; //5 private static final Color MODERATE_DAMAGE_COLOUR = new Color(10, 70, 190, 255); // Color.MAGENTA; //6 private static final Color SEVERE_DAMAGE_COLOUR = new Color(1, 50, 140, 255); // Color.CYAN; //7 private static final Color BURNT_OUT_COLOUR = Color.DARK_GRAY.darker(); // 8 private static final Color PROB = Color.PINK; // private static final Color REFUGE_BUILDING_COLOR = Color.GREEN.darker(); // private static final Color CENTER_BUILDING_COLOR = Color.WHITE.brighter().brighter(); // // private static final Color BURNING_REFUGE_COLOR = Color.RED.darker().darker(); private static final Stroke WALL_STROKE = new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); private static final Stroke ENTRANCE_STROKE = new BasicStroke(0.2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); // public static Map<EntityID, Collection<StandardEntity>> BURNING_BUILDINGS_MAP = new // FastMap<EntityID, Collection<StandardEntity>>(); public static Map<EntityID, List<MrlBuilding>> BURNING_BUILDINGS_MAP = Collections.synchronizedMap(new FastMap<EntityID, List<MrlBuilding>>()); public static Set<EntityID> BURNING_BUILDINGS = new FastSet<EntityID>(); /** Construct a building view layer. */ public MrlBurningBuildingLayer() { super(Building.class); } @Override public String getName() { return "Burning Buildings"; } @Override protected void paintEdge(Edge e, Graphics2D g, ScreenTransform t) { g.setColor(OUTLINE_COLOUR); g.setStroke(e.isPassable() ? ENTRANCE_STROKE : WALL_STROKE); g.drawLine( t.xToScreen(e.getStartX()), t.yToScreen(e.getStartY()), t.xToScreen(e.getEndX()), t.yToScreen(e.getEndY())); } @Override protected void paintShape(Building b, Polygon shape, Graphics2D g) { if (StaticViewProperties.selectedObject != null) { BURNING_BUILDINGS.clear(); List<MrlBuilding> buildings = null; try { buildings = Collections.synchronizedList( BURNING_BUILDINGS_MAP.get(StaticViewProperties.selectedObject.getID())); } catch (NullPointerException ignored) { } if (buildings != null) { showRealFieriness = true; for (MrlBuilding bb : buildings) { // if (bb.getEstimatedFieryness() > 0 && // b.equals(bb.getSelfBuilding())) { if (bb.getSelfBuilding().isFierynessDefined() && bb.getSelfBuilding().getFieryness() > 0 && b.equals(bb.getSelfBuilding())) { drawBurningBuildings(bb, shape, g); BURNING_BUILDINGS.add(bb.getSelfBuilding().getID()); return; } // else if (bb.isProbablyOnFire() && b.equals(bb.getSelfBuilding())) { // g.setColor(PROB); // g.fill(shape); // return; // } } } else { showRealFieriness = false; } } } private void drawBurningBuildings(MrlBuilding b, Shape shape, Graphics2D g) { // switch (b.getEstimatedFieryness()) { switch (b.getSelfBuilding().getFieryness()) { case 1: g.setColor(HEATING_COLOUR); break; case 2: g.setColor(BURNING_COLOUR); break; case 3: g.setColor(INFERNO_COLOUR); break; case 4: g.setColor(WATER_DAMAGE_COLOUR); break; case 5: g.setColor(MINOR_DAMAGE_COLOUR); break; case 6: g.setColor(MODERATE_DAMAGE_COLOUR); break; case 7: g.setColor(SEVERE_DAMAGE_COLOUR); break; case 8: g.setColor(BURNT_OUT_COLOUR); break; } g.fill(shape); } // private void drawFieriness(Building b, Polygon shape, Graphics2D g) { // StandardEntityToPaint entityToPaint = StaticViewProperties.getPaintObject(b); // if (entityToPaint != null) { // g.setColor(entityToPaint.getColor()); // g.fill(shape); // return; // } // if (b instanceof Refuge) { // g.setColor(REFUGE_BUILDING_COLOR); // if (b.isFierynessDefined() && b.getFieryness() > 0) { // g.setColor(BURNING_REFUGE_COLOR); // } // g.fill(shape); // } else if ((b instanceof AmbulanceCentre) || (b instanceof FireStation) || (b instanceof // PoliceOffice)) { // g.setColor(CENTER_BUILDING_COLOR); // if (b.isFierynessDefined() && b.getFieryness() > 0) { // g.setColor(BURNING_REFUGE_COLOR); // } // g.fill(shape); // } // if (!b.isFierynessDefined()) { // return; // } // switch (b.getFierynessEnum()) { // case UNBURNT: // return; // case HEATING: // g.setColor(HEATING); // break; // case BURNING: // g.setColor(BURNING); // break; // case INFERNO: // g.setColor(INFERNO); // break; // case WATER_DAMAGE: // g.setColor(WATER_DAMAGE); // break; // case MINOR_DAMAGE: // g.setColor(MINOR_DAMAGE); // break; // case MODERATE_DAMAGE: // g.setColor(MODERATE_DAMAGE); // break; // case SEVERE_DAMAGE: // g.setColor(SEVERE_DAMAGE); // break; // case BURNT_OUT: // g.setColor(BURNT_OUT); // break; // default: // throw new IllegalArgumentException("Don't know how to render fieriness " + // b.getFierynessEnum()); // } // g.fill(shape); // } // // private void drawBrokenness(Building b, Shape shape, Graphics2D g) { // int brokenness = b.getBrokenness(); // // CHECK STYLE:OFF:MagicNumber // int colour = Math.max(0, 135 - brokenness / 2); // // CHECK STYLE:ON:MagicNumber // g.setColor(new Color(colour, colour, colour)); // g.fill(shape); // } @Override public void initialise(Config config) {} }
public void paintComponent(Graphics paramGraphics) { super.paintComponent(paramGraphics); paramGraphics.setColor(Color.GRAY.darker().darker()); paramGraphics.fillRect(0, 0, getWidth(), getHeight()); int i = 0; Iterator<CardValueType> localIterator = this.dealersHand.cardValueTypes.iterator(); while (localIterator.hasNext()) { CardValueType localCard1 = (CardValueType) localIterator.next(); paramGraphics.drawImage( this.cardImage[localCard1.getPlace()], this.coord[0].x + i, this.coord[0].y, this); i = i + 75; } for (int j = 0; j < this.numberOfHands; j++) { i = 0; localIterator = this.playersHand[j].cardValueTypes.iterator(); while (localIterator.hasNext()) { CardValueType localCard2 = (CardValueType) localIterator.next(); paramGraphics.drawImage( this.cardImage[localCard2.getPlace()], this.coord[1].x + 560 * j / this.numberOfHands + i, this.coord[1].y, this); i += 75 / this.numberOfHands; } if ((!this.gameOver) || (j == 0)) { paramGraphics.drawImage( this.chipImage[(this.betAmount - 1)], this.coord[1].x + 560 * j / this.numberOfHands + 10, this.coord[1].y + 90, this); } if (this.doubledBet[j] != false) { paramGraphics.drawImage( this.chipImage[(this.betAmount - 1)], this.coord[1].x + 560 * j / this.numberOfHands + 35, this.coord[1].y + 100, this); } if (this.playersHand[j].busted()) { paramGraphics.drawImage( this.bustedImage, this.coord[1].x + 560 * j / this.numberOfHands + 5, this.coord[1].y + 45, this); } else if (this.dealersHand.busted()) { paramGraphics.drawImage( this.winnerImage, this.coord[1].x + 560 * j / this.numberOfHands + 5, this.coord[1].y + 45, this); } else if ((this.dealersHand.getValue() > this.playersHand[j].getValue()) && (this.gameOver)) { paramGraphics.drawImage( this.loserImage, this.coord[1].x + 560 * j / this.numberOfHands + 5, this.coord[1].y + 45, this); } else if ((this.dealersHand.getValue() < this.playersHand[j].getValue()) && (this.gameOver)) { paramGraphics.drawImage( this.winnerImage, this.coord[1].x + 560 * j / this.numberOfHands + 5, this.coord[1].y + 45, this); } else if (this.gameOver) { paramGraphics.drawImage( this.pushImage, this.coord[1].x + 560 * j / this.numberOfHands + 5, this.coord[1].y + 45, this); } } if ((this.numberOfHands > 1) && (!this.gameOver)) { paramGraphics.drawImage( this.fingerImage, this.coord[1].x + 560 * this.currentHand / this.numberOfHands + 30, this.coord[1].y - 45, this); } }
/** * Attribute values for the nodes and edges. * * @author Arend rensink * @version $Revision $ */ public class Values { /** Dash pattern of absent graphs and transitions. */ public static final float[] ABSENT_DASH = new float[] {3.0f, 3.0f}; /** Dash pattern of abstract type nodes and edges. */ public static final float[] ABSTRACT_DASH = new float[] {6.0f, 2.0f}; /** Dash pattern of connect edges. */ public static final float[] CONNECT_DASH = new float[] {2f, 4f}; /** Dash pattern for verdict edges. */ public static final float[] VERDICT_DASH = new float[] {4.0f, 3.0f}; /** No dash pattern. */ public static final float[] NO_DASH = new float[] {10.f, 0.f}; /** Foreground colour of creator nodes and edges. */ public static final Color CREATOR_FOREGROUND = Color.green.darker(); /** Background colour of creator nodes and edges. */ public static final Color CREATOR_BACKGROUND = null; /** The default foreground colour used for edges and nodes. */ public static final Color DEFAULT_FOREGROUND = Color.black; /** The default background colour used for nodes. */ public static final Color DEFAULT_BACKGROUND = Colors.findColor("243 243 243"); /** Dash pattern of embargo nodes and edges. */ public static final float[] EMBARGO_DASH = new float[] {2f, 2f}; /** Foreground colour of embargo nodes and edges. */ public static final Color EMBARGO_FOREGROUND = Color.RED; /** Background colour of embargo nodes and edges. */ public static final Color EMBARGO_BACKGROUND = null; /** Dash pattern of eraser nodes and edges. */ public static final float[] ERASER_DASH = new float[] {4f, 4f}; /** Foreground colour of eraser nodes and edges. */ public static final Color ERASER_FOREGROUND = Color.BLUE; /** Background colour of eraser nodes and edges. */ public static final Color ERASER_BACKGROUND = Colors.findColor("200 240 255"); /** Dash pattern of nesting nodes and edges. */ public static final float[] NESTED_DASH = new float[] {2.0f, 3.0f}; /** Colour used for nesting nodes and states. */ public static final Color NESTED_COLOR = Colors.findColor("165 42 42"); /** Foreground colour of remark nodes and edges. */ public static final Color REMARK_FOREGROUND = Colors.findColor("255 140 0"); /** Background colour of remark nodes and edges. */ public static final Color REMARK_BACKGROUND = Colors.findColor("255 255 180"); /** Background colour of (normal) open states. */ public static final Color OPEN_BACKGROUND = Color.GRAY.brighter(); /** Background colour of final states. */ public static final Color FINAL_BACKGROUND = Colors.findColor("0 200 0"); /** Foreground colour of result states. */ public static final Color RESULT_FOREGROUND = JAttr.STATE_BACKGROUND; /** Background colour of result states. */ public static final Color RESULT_BACKGROUND = Colors.findColor("92 125 23"); /** Background colour of error states. */ public static final Color ERROR_BACKGROUND = Color.RED; /** Foreground colour of the start state. */ public static final Color START_FOREGROUND = JAttr.STATE_BACKGROUND; /** Background colour of the start state. */ public static final Color START_BACKGROUND = Color.BLACK; /** Background colour of the start state while it is still open. */ public static final Color START_OPEN_BACKGROUND = Color.GRAY.darker(); /** Foreground colour for active nodes and edges. */ public static final Color ACTIVE_COLOR = Color.BLUE; /** Foreground colour for the active start node. */ public static final Color ACTIVE_START_COLOR = Colors.findColor("40 200 255"); /** Foreground colour for an active final node. */ public static final Color ACTIVE_FINAL_COLOR = Colors.findColor("30 100 200"); /** Colour used for transient states. */ public static final Color RECIPE_COLOR = Colors.findColor("165 42 42"); /** Colour used for transient active states. */ public static final Color ACTIVE_RECIPE_COLOR = Colors.findColor("165 42 149"); /** Background colour used for selected items in focused lists. */ public static final Color FOCUS_BACKGROUND = Color.DARK_GRAY; /** Text colour used for selected items in focused lists. */ public static final Color FOCUS_FOREGROUND = Color.WHITE; /** Background colour used for selected items in non-focused lists. */ public static final Color SELECT_BACKGROUND = Color.LIGHT_GRAY; /** Text colour used for selected items in non-focused lists. */ public static final Color SELECT_FOREGROUND = Color.BLACK; /** Background colour used for non-selected items in lists. */ public static final Color NORMAL_BACKGROUND = Color.WHITE; /** Text colour used for non-selected items in lists. */ public static final Color NORMAL_FOREGROUND = Color.BLACK; /** Text display colours to be used in normal display mode. */ public static final Values.ColorSet NORMAL_COLORS = new Values.ColorSet(); static { NORMAL_COLORS.putColors(FOCUSED, FOCUS_FOREGROUND, FOCUS_BACKGROUND); NORMAL_COLORS.putColors(SELECTED, SELECT_FOREGROUND, SELECT_BACKGROUND); NORMAL_COLORS.putColors(NONE, NORMAL_FOREGROUND, NORMAL_BACKGROUND); } /** Colour used for indicating errors in graphs. */ public static final Color ERROR_COLOR = new Color(255, 50, 0, 40); /** Background colour used for focused error items in lists. */ public static final Color ERROR_FOCUS_BACKGROUND = Color.RED.darker().darker(); /** Text colour used for focused error items in lists. */ public static final Color ERROR_FOCUS_FOREGROUND = Color.WHITE; /** Background colour used for selected, non-focused error items in lists. */ public static final Color ERROR_SELECT_BACKGROUND = ERROR_COLOR; /** Text colour used for selected, non-focused error items in lists. */ public static final Color ERROR_SELECT_FOREGROUND = Color.RED; /** Background colour used for non-selected, non-focused error items in lists. */ public static final Color ERROR_NORMAL_BACKGROUND = Color.WHITE; /** Text colour used for non-selected, non-focused error items in lists. */ public static final Color ERROR_NORMAL_FOREGROUND = Color.RED; /** Text display colours to be used in error mode. */ public static final Values.ColorSet ERROR_COLORS = new Values.ColorSet(); static { ERROR_COLORS.putColors(FOCUSED, ERROR_FOCUS_FOREGROUND, ERROR_FOCUS_BACKGROUND); ERROR_COLORS.putColors(SELECTED, ERROR_SELECT_FOREGROUND, ERROR_SELECT_BACKGROUND); ERROR_COLORS.putColors(NONE, ERROR_NORMAL_FOREGROUND, ERROR_NORMAL_BACKGROUND); } /** Text display colours to be used for transient states. */ public static final Values.ColorSet RECIPE_COLORS = new Values.ColorSet(); static { RECIPE_COLORS.putColors(FOCUSED, Color.WHITE, RECIPE_COLOR.darker()); RECIPE_COLORS.putColors(SELECTED, RECIPE_COLOR.darker(), SELECT_BACKGROUND); RECIPE_COLORS.putColors(NONE, RECIPE_COLOR, NORMAL_BACKGROUND); } /** Colour of forbidden property labels. */ public static final Color FORBIDDEN_COLOR = ERROR_COLOR; /** Colour of invariant property labels. */ public static final Color INVARIANT_COLOR = CREATOR_FOREGROUND; /** Line style that always makes right edges. */ public static final int STYLE_MANHATTAN = 14; /** Cell selection modes in trees or lists. */ public static enum Mode { /** Focused selection. */ FOCUSED, /** Normal selection. */ SELECTED, /** No selection. */ NONE; /** Converts a pair of boolean values into a selection mode. */ public static Mode toMode(boolean selected, boolean focused) { if (focused) { return Mode.FOCUSED; } else if (selected) { return Mode.SELECTED; } else { return Mode.NONE; } } } /** Set of colours per selection mode. */ public static class ColorSet extends DefaultFixable { /** Adds the foreground and background colours for a given selection mode. */ public void putColors(Mode mode, Color foreground, Color background) { testFixed(false); Color oldFore = this.foreColors.put(mode, foreground); assert oldFore == null; Color oldBack = this.backColors.put(mode, background); assert oldBack == null; if (this.foreColors.size() == Mode.values().length) { setFixed(); } } /** * Returns the foreground colour for the mode indicated by the parameters. * * @param selected if {@code true}, use selection mode * @param focused if {@code true}, use focused mode * @return the colour for the relevant mode */ public Color getForeground(boolean selected, boolean focused) { return getColor(this.foreColors, selected, focused); } /** * Returns the foreground colour for the given selection mode * * @return the colour for the relevant mode */ public Color getForeground(Mode mode) { return this.foreColors.get(mode); } /** * Returns the background colour for the mode indicated by the parameters. * * @param selected if {@code true}, use selection mode * @param focused if {@code true}, use focused mode * @return the colour for the relevant mode */ public Color getBackground(boolean selected, boolean focused) { return getColor(this.backColors, selected, focused); } /** * Returns the background colour for the given selection mode * * @return the colour for the relevant mode */ public Color getBackground(Mode mode) { return this.backColors.get(mode); } private Color getColor(Map<Mode, Color> colors, boolean selected, boolean focused) { return colors.get(Mode.toMode(selected, focused)); } private final Map<Mode, Color> foreColors = new EnumMap<Mode, Color>(Mode.class); private final Map<Mode, Color> backColors = new EnumMap<Mode, Color>(Mode.class); } }
public ConfigTestsView() { // default look and feel try { // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); // UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); // UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticLookAndFeel"); // UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); // UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); // UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); // //10 // UIManager.setLookAndFeel("com.jgoodies.looks.windows.WindowsLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.aero.AeroLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.bernstein.BernsteinLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.fast.FastLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.graphite.GraphiteLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel"); // //8 // UIManager.setLookAndFeel("com.jtattoo.plaf.luna.LunaLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.mcwin.McWinLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.mint.MintLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.noire.NoireLookAndFeel"); // //8 // UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel"); UIManager.setLookAndFeel("com.jtattoo.plaf.texture.TextureLookAndFeel"); // 10 // UIManager.setLookAndFeel("com.pagosoft.plaf.PgsLookAndFeel"); JFrame.setDefaultLookAndFeelDecorated(false); } catch (Exception e) { e.printStackTrace(); JFrame.setDefaultLookAndFeelDecorated(true); } // Colors Palette palette = new Palette(); super.getContentPane().setBackground(Color.GRAY.darker()); // On close super.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); super.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent event) { dispose(); } }); // axis divisions int maxx = 32; int maxy = 24; // Screen size Dimension dim = new Dimension(800, 600); super.setSize(dim); super.setUndecorated(true); // Dimensions int[] x = new int[maxx]; int[] y = new int[maxy]; int long_x = (int) (dim.getWidth() / x.length); int long_y = (int) (dim.getHeight() / y.length); // Grid for controls Container frameContentPane = super.getContentPane(); frameContentPane.setLayout(new GridBagLayout()); for (int i = 0; i < x.length; i++) x[i] = long_x; for (int i = 0; i < y.length; i++) y[i] = long_y; ((GridBagLayout) frameContentPane.getLayout()).columnWidths = x; ((GridBagLayout) frameContentPane.getLayout()).rowHeights = y; // Add controls PzrPanel _A = new PzrPanel(palette.getColor(Palette.COLOR_CAPTION)); PzrPanel _B = new PzrPanel(palette.getColor(Palette.COLOR_BACKGROUND)); PzrPanel _C = new PzrPanel(palette.getColor("#FFFFFF")); _A.setBorder(BorderFactory.createLineBorder(palette.getColor(Palette.COLOR_BORDER))); // Add controls frameContentPane.add( _A, new GridBagConstraints( 0, 0, maxx, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); frameContentPane.add( _B, new GridBagConstraints( 0, 2, maxx, maxy - 5, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); frameContentPane.add( _C, new GridBagConstraints( 0, maxy - 3, maxx, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // title lblCaption = new PzrLabel( 0, (int) (long_y * 0.5), long_x * maxx, long_y * 1, "", palette.getColor("#FFFFFF"), new Font("Verdana", Font.BOLD, 16)); lblCaption.setHorizontalAlignment(SwingConstants.LEFT); lblCaption.setVerticalTextPosition(SwingConstants.CENTER); _A.add(lblCaption); _A.add( new PzrImage( (long_x * (maxx - 9)) - 5, (int) (long_y * 0.5), long_x * 9, long_y * 1, "/gui/image/logo_small.png")); // Controls int height = (int) (long_y * 1.4); int top = long_y * 1; int left = long_x * 1; int width = long_x * 9; Font font = new Font("Verdana", Font.BOLD, 16); lblName = new PzrLabel( left, top * 3, width, height, "Name", Color.BLACK, font, SwingConstants.RIGHT, SwingConstants.CENTER); lblDescription = new PzrLabel( left, top * 5, width, height, "Description", Color.BLACK, font, SwingConstants.RIGHT, SwingConstants.CENTER); // height = (int) (long_y * 1.4); top = long_y * 1; left = long_x * 11; width = long_x * 18; font = new Font("Verdana", Font.PLAIN, 16); txtName = new PzrText(left, top * 3, width, height, "txtName", font, true); txtDescription = new PzrTextArea("txtDescription", font, false); PzrScrollPane scrollPane = new PzrScrollPane(left, top * 5, width, height * 5, txtDescription); _B.add(lblName); _B.add(lblDescription); _B.add(txtName); _B.add(scrollPane); // OK button this.btnOK = new PzrButton( long_x * 0, long_y * 0, long_x * maxx / 2, long_y * 3, "btnOK", "OK", palette.getColor(Palette.COLOR_OK), BorderFactory.createLineBorder(Color.white)); this.btnOK.setForeground(palette.getColor("#FFFFFF")); this.btnOK.repaint("/gui/image/form_ok.png", 32, 32); this.btnOK.setHorizontalTextPosition(SwingConstants.RIGHT); this.btnOK.setVerifyInputWhenFocusTarget(false); // Cancel button this.btnCancel = new PzrButton( long_x * maxx / 2, long_y * 0, long_x * maxx / 2, long_y * 3, "btnCancel", "Cancel", palette.getColor(Palette.COLOR_CANCEL), BorderFactory.createLineBorder(Color.white)); this.btnCancel.setForeground(palette.getColor("#FFFFFF")); this.btnCancel.repaint("/gui/image/form_cancel.png", 32, 32); this.btnCancel.setHorizontalTextPosition(SwingConstants.RIGHT); this.btnCancel.setVerifyInputWhenFocusTarget(false); // Add buttons _C.add(this.btnOK); _C.add(this.btnCancel); // Show this.setUndecorated(true); this.getRootPane().setWindowDecorationStyle(JRootPane.NONE); this.setLocationRelativeTo(null); this.setModal(true); }
public GamePanel(MainFrame mainFrame) { directionPaint = new DirectionPaint(); matchManager = new MatchManager(); stickPaint = new StickPaint(); howToPlay = HowToPlay.MevsMe; this.addMouseListener(this); this.addMouseMotionListener(this); this.principalMainFrame = mainFrame; this.setLayout(null); setSize(new Dimension(MatchManager.WIDTH, MatchManager.HEIGHT)); requestFocus(true); setMinimumSize(new Dimension(MatchManager.WIDTH, MatchManager.HEIGHT)); setPreferredSize(new Dimension(MatchManager.WIDTH, MatchManager.HEIGHT)); setBackground(Color.GRAY.darker().darker()); addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == FileProvider.getCommand(CommandSetting.PAUSE)) { setImageScreenFile(); FileProvider.setCurrentStepOfTheGameString( matchManager.getCurrentStatusOfTheGame().toString()); matchManager.setPause(true); mainFrame.switchToPausePanel(); } if (matchManager.getIAmPlayingWithIa() && matchManager.getIsPlayer1Turn() || !matchManager.getIAmPlayingWithIa()) { if (e.getKeyCode() == FileProvider.getCommand(CommandSetting.DIRECTION_RIGHT)) if (matchManager.getWhiteBallReposition()) { matchManager.getWhiteball().setDirection(Direction.RIGHT); matchManager.setRepositionWithMouse(false); } else matchManager.getStick().setStickDirection(Direction.RIGHT); if (e.getKeyCode() == FileProvider.getCommand(CommandSetting.DIRECTION_LEFT)) if (matchManager.getWhiteBallReposition()) { matchManager.getWhiteball().setDirection(Direction.LEFT); matchManager.setRepositionWithMouse(false); } else matchManager.getStick().setStickDirection(Direction.LEFT); matchManager.setRepositionWithMouse(false); if (e.getKeyCode() == FileProvider.getCommand(CommandSetting.INCREMENT_POWER)) if (matchManager.getWhiteBallReposition()) { matchManager.getWhiteball().setDirection(Direction.UP); matchManager.setRepositionWithMouse(false); } else matchManager.getPowerIndicator().setPowerType(DirectionOfPower.INCREMENT); if (e.getKeyCode() == FileProvider.getCommand(CommandSetting.DECREMENT_POWER)) if (matchManager.getWhiteBallReposition()) { matchManager.getWhiteball().setDirection(Direction.DOWN); matchManager.setRepositionWithMouse(false); } else matchManager.getPowerIndicator().setPowerType(DirectionOfPower.DECREMENT); if (e.getKeyCode() == FileProvider.getCommand(CommandSetting.HIT)) if (matchManager.getWhiteBallReposition()) { matchManager.setWhiteBallReposition(); flag = false; } else matchManager.getStick().setHit(true); } }; @Override public void keyReleased(KeyEvent e) { super.keyReleased(e); if (matchManager.getIAmPlayingWithIa() && matchManager.getIsPlayer1Turn() || !matchManager.getIAmPlayingWithIa()) { if (matchManager.getWhiteBallReposition()) matchManager.getWhiteball().setDirection(Direction.STOP); else { matchManager.getStick().setStickDirection(Direction.STOP); matchManager.getPowerIndicator().setPowerType(DirectionOfPower.NOTHING); } } } }); }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); ((Graphics2D) g) .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (matchManager.getPlayer1Win() || matchManager.getPlayer2Win()) { if (matchManager.canPrintWinOrLose()) { if (matchManager.getIAmPlayingWithIa() && matchManager.getPlayer1Win()) g.drawImage(ImageProvider.getYouWin(), 300, 300, null); else if (matchManager.getIAmPlayingWithIa() && matchManager.getPlayer2Win()) g.drawImage(ImageProvider.getYouLose(), 300, 300, null); else g.drawImage(ImageProvider.getYouWin(), 300, 300, null); } else { principalMainFrame.returnToInitialPanel(); } Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f)); } g.drawImage( ImageProvider.tableImage.get(FileProvider.getCommand(CommandSetting.INDEX_TABLE_SELECTED)), matchManager.getTable().getX() - 49, matchManager.getTable().getY() - 45, null); g.setColor(Color.RED); long second1Match = ((matchManager.getMaxWaitTimeForTheTurn() - matchManager.getChronometerOfTheTurn().getElapsedTime()) - 1) / 10; long second2Match = ((matchManager.getMaxWaitTimeForTheTurn() - matchManager.getChronometerOfTheTurn().getElapsedTime()) - 1) % 10; if (second1Match != 0) g.drawImage(ImageProvider.getNumber((int) second1Match), 300, 100, null); g.drawImage(ImageProvider.getNumber((int) second2Match), 330, 100, null); long minute1 = matchManager.getChronometerOfTheMatch().getMinute() / 10; long minute2 = matchManager.getChronometerOfTheMatch().getMinute() % 10; long second1 = matchManager.getChronometerOfTheMatch().getElapsedTime() % 60 / 10; long second2 = matchManager.getChronometerOfTheMatch().getElapsedTime() % 60 % 10; g.drawImage(ImageProvider.getNumber((int) minute1), 640, 100, null); g.drawImage(ImageProvider.getNumber((int) minute2), 670, 100, null); g.drawImage(ImageProvider.getNumber(10), 700, 102, null); g.drawImage(ImageProvider.getNumber((int) second1), 730, 100, null); g.drawImage(ImageProvider.getNumber((int) second2), 760, 100, null); if (matchManager.getIsThirdStepOfTheGame()) { if (matchManager.getPlayerA().getColorBall() == ColorBall.YELLOW) { if (matchManager.getYellowBall().size() < MatchManager.MAX_SIZE_SET_OF_BALL_PLAYER) g.drawImage( ImageProvider.containerYellowBall.get(matchManager.getYellowBall().size()), 150, 700, null); else if (matchManager.getYellowBall().size() == MatchManager.MAX_SIZE_SET_OF_BALL_PLAYER) g.drawImage(ImageProvider.getContainerBlackBall(), 150, 700, null); if (matchManager.getRedBall().size() < MatchManager.MAX_SIZE_SET_OF_BALL_PLAYER) g.drawImage( ImageProvider.containerRedBall.get(matchManager.getRedBall().size()), 800, 700, null); else if (matchManager.getRedBall().size() == MatchManager.MAX_SIZE_SET_OF_BALL_PLAYER) g.drawImage(ImageProvider.getContainerBlackBall(), 800, 700, null); } else { if (matchManager.getYellowBall().size() < MatchManager.MAX_SIZE_SET_OF_BALL_PLAYER) g.drawImage( ImageProvider.containerYellowBall.get(matchManager.getYellowBall().size()), 800, 700, null); else if (matchManager.getYellowBall().size() == MatchManager.MAX_SIZE_SET_OF_BALL_PLAYER) g.drawImage(ImageProvider.getContainerBlackBall(), 800, 700, null); if (matchManager.getRedBall().size() < MatchManager.MAX_SIZE_SET_OF_BALL_PLAYER) g.drawImage( ImageProvider.containerRedBall.get(matchManager.getRedBall().size()), 150, 700, null); else if (matchManager.getRedBall().size() == MatchManager.MAX_SIZE_SET_OF_BALL_PLAYER) g.drawImage(ImageProvider.getContainerBlackBall(), 150, 700, null); } } if (matchManager.getIsPlayer1Turn()) { g.setColor(Color.RED); if (matchManager.getPlayerA().getColorBall() == ColorBall.RED) g.drawString("Player 1 Turn Color RED", 50, 50); if (matchManager.getPlayerA().getColorBall() == ColorBall.YELLOW) g.drawString("Player 1 Turn Color YELLOW", 50, 50); if (matchManager.getPlayerA().getColorBall() == ColorBall.NOTHING) g.drawString("Player 1 Turn Color NOTHING", 50, 50); } if (matchManager.getIsPlayer2Turn()) { g.setColor(Color.BLUE); if (matchManager.getPlayerB().getColorBall() == ColorBall.RED) g.drawString("Player 2 Turn Color RED", 50, 50); if (matchManager.getPlayerB().getColorBall() == ColorBall.YELLOW) g.drawString("Player 2 Turn Color YELLOW", 50, 50); if (matchManager.getPlayerB().getColorBall() == ColorBall.NOTHING) g.drawString("Player 2 Turn Color NOTHING", 50, 50); } if (matchManager.getIsFisrtStepOfTheGame()) g.drawString("First Step", 100, 100); else if (matchManager.getIsSecondStepOfTheGame()) g.drawString("Second Step", 100, 100); else if (matchManager.getIsThirdStepOfTheGame()) g.drawString("Third Step", 100, 100); g.setColor(Color.ORANGE.darker().darker()); if (matchManager.getWhiteBallReposition() && !flag) { if (matchManager.getIsPlayer1Turn() && matchManager.getIAmPlayingWithIa()) g.drawString( "PLEASE REPOSITION WHITE BALL, WHEN YOU FINISH TO REPOSITION PRESS SPACE", 400, 100); else if (matchManager.getIsPlayer2Turn() && matchManager.getIAmPlayingWithIa()) g.drawString("THE ARTIFICIAL PLAYER IS REPOSITIONING WHITE BALL", 400, 100); else if (!matchManager.getIAmPlayingWithIa()) g.drawString( "PLEASE REPOSITION WHITE BALL, WHEN YOU FINISH TO REPOSITION PRESS SPACE", 400, 100); } for (Ball b : matchManager.getBalls()) { if (!b.getIsPocketed()) { if (b.getIdentificativeNumber() == 0) g.drawImage(ImageProvider.getWhiteBall(), b.getX(), b.getY(), null); if (b.getIdentificativeNumber() == 8) g.drawImage(ImageProvider.getBlackBall(), b.getX(), b.getY(), null); if (b.getIdentificativeNumber() >= 1 && b.getIdentificativeNumber() <= 7) g.drawImage(ImageProvider.getYellowBall(), b.getX(), b.getY(), null); if (b.getIdentificativeNumber() >= 9 && b.getIdentificativeNumber() <= 15) g.drawImage(ImageProvider.getRedBall(), b.getX(), b.getY(), null); } } g.drawImage( ImageProvider.getPowerIndicator(), matchManager.getPowerIndicator().getX(), matchManager.getPowerIndicator().getY(), null); g.drawImage( ImageProvider.getArrow(), matchManager.getPowerIndicator().getArrowIndicator().getX(), matchManager.getPowerIndicator().getArrowIndicator().getY(), null); g.setColor(Color.GRAY.brighter().brighter().brighter()); g.setColor(Color.RED); if (matchManager.getFoulBallHitTheOppositeColor() && matchManager.canPrintFoul()) { g.drawImage( ImageProvider.firstBallTouchedIsTheOppositeColorFoul.get(matchManager.getIndexTable()), 400, 700, null); } if (matchManager.getFoulWhiteBallPocketed() && matchManager.canPrintFoul()) { g.drawImage( ImageProvider.whiteBallFoulImage.get(matchManager.getIndexTable()), 400, 700, null); } if (matchManager.getFoulNoneBallTouched() && matchManager.canPrintFoul()) { g.drawImage( ImageProvider.noneBallTouchedFoulImage.get(matchManager.getIndexTable()), 400, 700, null); } if (matchManager.getPhysicsBallMovement().everyBallStopped(matchManager.getBalls()) && !matchManager.getWhiteBallReposition()) { stickPaint.paint( g, matchManager.getStick().getAngle(), matchManager.getStick().getX(), matchManager.getStick().getY()); if (matchManager.getIsPlayer1Turn() && matchManager.getIAmPlayingWithIa() || !matchManager.getIAmPlayingWithIa()) directionPaint.paint( g, matchManager.getStick().getAngle(), matchManager.getStick().getX(), matchManager.getStick().getY()); } }
@Override public void debug(Edge edge) { dv.addDebug(new DisplayLineSegment2d(edge.getBegin(), edge.getEnd(), Color.GRAY.darker())); }
public TaskGridView() { // default look and feel try { // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); // UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); // UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticLookAndFeel"); // UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); // UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); // UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); //10 // UIManager.setLookAndFeel("com.jgoodies.looks.windows.WindowsLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.aero.AeroLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.bernstein.BernsteinLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.fast.FastLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.graphite.GraphiteLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel"); //8 // UIManager.setLookAndFeel("com.jtattoo.plaf.luna.LunaLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.mcwin.McWinLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.mint.MintLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.noire.NoireLookAndFeel"); //8 // UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel"); UIManager.setLookAndFeel("com.jtattoo.plaf.texture.TextureLookAndFeel"); // 10 // UIManager.setLookAndFeel("com.pagosoft.plaf.PgsLookAndFeel"); JFrame.setDefaultLookAndFeelDecorated(false); } catch (Exception e) { e.printStackTrace(); JFrame.setDefaultLookAndFeelDecorated(true); } // Colors Palette palette = new Palette(); super.getContentPane().setBackground(Color.GRAY.darker()); // On close super.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); super.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent event) { dispose(); } }); // axis divisions int maxx = 64; int maxy = 48; // Screen size Dimension dim = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getSize(); // Dimension dim = super.getToolkit().getScreenSize(); // Dimension dim = new Dimension(1024, 768); super.setSize(dim); super.setUndecorated(true); // Dimensions int[] x = new int[maxx]; int[] y = new int[maxy]; int long_x = (int) (dim.getWidth() / x.length); int long_y = (int) (dim.getHeight() / y.length); // Grid for controls Container frameContentPane = super.getContentPane(); frameContentPane.setLayout(new GridBagLayout()); for (int i = 0; i < x.length; i++) x[i] = long_x; for (int i = 0; i < y.length; i++) y[i] = long_y; ((GridBagLayout) frameContentPane.getLayout()).columnWidths = x; ((GridBagLayout) frameContentPane.getLayout()).rowHeights = y; // Panels PzrPanel _A = new PzrPanel(palette.getColor("#447744")); PzrPanel _B = new PzrPanel(palette.getColor("#FFFFFF")); PzrPanel _C = new PzrPanel(palette.getColor("#000000")); PzrPanel _D = new PzrPanel(palette.getColor("#FFFFFF")); _A.setBorder(BorderFactory.createLineBorder(Color.white)); // frameContentPane.add( _A, new GridBagConstraints( 0, 0, maxx, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); frameContentPane.add( _B, new GridBagConstraints( 0, 3, maxx, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); frameContentPane.add( _C, new GridBagConstraints( 0, 6, maxx, maxy - 9, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); frameContentPane.add( _D, new GridBagConstraints( 0, maxy - 3, maxx, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // Title lblCaption = new PzrLabel( 0, 0, long_x * maxx, long_y * 3, "Tests", palette.getColor("#FFFFFF"), new Font("Verdana", Font.BOLD, 18)); lblCaption.setHorizontalAlignment(SwingConstants.CENTER); _A.add(lblCaption); _A.add( new PzrImage( (long_x * 0) + 5, (int) (long_y * 1), long_x * 9, (int) (long_y * 1), "/gui/image/logo_small.png")); // Close this.btnClose = new PzrButton( (long_x * (maxx - 8)) - 1, (long_y * 0) + 1, long_x * 8, (long_y * 3) - 2, "btnClose", "Close", palette.getColor("#A20025"), ""); this.btnClose.setOpaque(false); this.btnClose.setForeground(palette.getColor("#FFFFFF")); this.btnClose.repaint("/gui/image/grid_close_1.png", 32, 32); this.btnClose.setHorizontalTextPosition(SwingConstants.RIGHT); _A.add(this.btnClose); // Buttons top menu this.btnNew = new PzrButton( long_x * 0, long_y * 0, long_x * 8, long_y * 3, "btnNew", "New", palette.getColor("#DFF2BF"), ""); this.btnNew.setOpaque(false); this.btnNew.setForeground(palette.getColor("#000000")); this.btnNew.repaint("/gui/image/grid_new_0.png", 32, 32); this.btnNew.setHorizontalTextPosition(SwingConstants.RIGHT); this.btnModify = new PzrButton( long_x * 8, long_y * 0, long_x * 8, long_y * 3, "btnModify", "Modify", palette.getColor("#BDE5F8"), ""); this.btnModify.setOpaque(false); this.btnModify.setForeground(palette.getColor("#000000")); this.btnModify.repaint("/gui/image/grid_edit_0.png", 32, 32); this.btnModify.setHorizontalTextPosition(SwingConstants.RIGHT); this.btnDelete = new PzrButton( long_x * 16, long_y * 0, long_x * 8, long_y * 3, "btnDelete", "Delete", palette.getColor("#FFBABA"), ""); this.btnDelete.setOpaque(false); this.btnDelete.setForeground(palette.getColor("#000000")); this.btnDelete.repaint("/gui/image/grid_delete_0.png", 32, 32); this.btnDelete.setHorizontalTextPosition(SwingConstants.RIGHT); this.btnPrint = new PzrButton( long_x * 24, long_y * 0, long_x * 8, long_y * 3, "btnPrint", "Print", palette.getColor("#FEEFB3"), ""); this.btnPrint.setOpaque(false); this.btnPrint.setForeground(palette.getColor("#000000")); this.btnPrint.repaint("/gui/image/grid_print_0.png", 32, 32); this.btnPrint.setHorizontalTextPosition(SwingConstants.RIGHT); this.btnDetail1 = new PzrButton( long_x * 32, long_y * 0, long_x * 8, long_y * 3, "btnDetail1", "", palette.getColor(255, 153, 255), ""); this.btnDetail1.setOpaque(false); this.btnDetail1.setForeground(palette.getColor("#000000")); this.btnDetail1.repaint("/gui/image/grid_roles_0.png", 32, 32); this.btnDetail1.setHorizontalTextPosition(SwingConstants.RIGHT); this.btnDetail2 = new PzrButton( long_x * 40, long_y * 0, long_x * 8, long_y * 3, "btnDetail2", "", palette.getColor(204, 153, 255), ""); this.btnDetail2.setOpaque(false); this.btnDetail2.setForeground(palette.getColor("#000000")); this.btnDetail2.repaint("/gui/image/grid_users_0.png", 32, 32); this.btnDetail2.setHorizontalTextPosition(SwingConstants.RIGHT); _B.add(this.btnNew); _B.add(this.btnModify); _B.add(this.btnDelete); _B.add(this.btnPrint); _B.add(this.btnDetail1); _B.add(this.btnDetail2); // Grid this.grdData = new PzrGrid(0, 0, long_x * maxx, long_y * (maxy - 9), new Font("Verdana", Font.PLAIN, 16)); _C.add(this.grdData); // Buttons bottom menu this.btnGridFirst = new PzrButton( long_x * 0, long_y * 0, long_x * 3, long_y * 3, "btnGridFirst", "", palette.getColor("#FFFFFF"), ""); this.btnGridFirst.setOpaque(false); this.btnGridFirst.setForeground(palette.getColor("#000000")); this.btnGridFirst.repaint("/gui/image/grid_first.png", 32, 32); this.btnGridPrevious = new PzrButton( long_x * 3, long_y * 0, long_x * 3, long_y * 3, "btnGridPrevious", "", palette.getColor("#FFFFFF"), ""); this.btnGridPrevious.setOpaque(false); this.btnGridPrevious.setForeground(palette.getColor("#000000")); this.btnGridPrevious.repaint("/gui/image/grid_previous.png", 32, 32); this.btnGridSet1 = new PzrButton( long_x * 6, long_y * 0, long_x * 3, long_y * 3, "btnGridSet1", "1", palette.getColor("#FFFFFF"), ""); this.btnGridSet1.setOpaque(false); this.btnGridSet1.setForeground(palette.getColor("#000000")); this.btnGridSet1.setFont(new Font("Verdana", Font.PLAIN, 18)); this.btnGridSet2 = new PzrButton( long_x * 9, long_y * 0, long_x * 3, long_y * 3, "btnGridSet2", "2", palette.getColor("#FFFFFF"), ""); this.btnGridSet2.setOpaque(false); this.btnGridSet2.setForeground(palette.getColor("#000000")); this.btnGridSet2.setFont(new Font("Verdana", Font.PLAIN, 18)); this.btnGridSet3 = new PzrButton( long_x * 12, long_y * 0, long_x * 3, long_y * 3, "btnGridSet3", "3", palette.getColor("#FFFFFF"), ""); this.btnGridSet3.setOpaque(false); this.btnGridSet3.setForeground(palette.getColor("#000000")); this.btnGridSet3.setFont(new Font("Verdana", Font.PLAIN, 18)); this.btnGridSet4 = new PzrButton( long_x * 15, long_y * 0, long_x * 3, long_y * 3, "btnGridSet4", "4", palette.getColor("#DFF2BF"), ""); this.btnGridSet4.setOpaque(false); this.btnGridSet4.setForeground(palette.getColor("#000000")); this.btnGridSet4.setFont(new Font("Verdana", Font.PLAIN, 18)); this.btnGridSet5 = new PzrButton( long_x * 18, long_y * 0, long_x * 3, long_y * 3, "btnGridSet5", "5", palette.getColor("#DFF2BF"), ""); this.btnGridSet5.setOpaque(false); this.btnGridSet5.setForeground(palette.getColor("#000000")); this.btnGridSet5.setFont(new Font("Verdana", Font.PLAIN, 18)); this.btnGridNext = new PzrButton( long_x * 21, long_y * 0, long_x * 3, long_y * 3, "btnGridNext", "", palette.getColor("#DFF2BF"), ""); this.btnGridNext.setOpaque(false); this.btnGridNext.setForeground(palette.getColor("#000000")); this.btnGridNext.repaint("/gui/image/grid_next.png", 32, 32); this.btnGridLast = new PzrButton( long_x * 24, long_y * 0, long_x * 3, long_y * 3, "btnGridLast", "", palette.getColor("#DFF2BF"), ""); this.btnGridLast.setOpaque(false); this.btnGridLast.setForeground(palette.getColor("#000000")); this.btnGridLast.repaint("/gui/image/grid_last.png", 32, 32); this.btnGridRefresh = new PzrButton( long_x * 27, long_y * 0, long_x * 3, long_y * 3, "btnGridRefresh", "", palette.getColor("#DFF2BF"), ""); this.btnGridRefresh.setOpaque(false); this.btnGridRefresh.setForeground(palette.getColor("#000000")); this.btnGridRefresh.repaint("/gui/image/grid_refresh.png", 32, 32); this.lblSearch = new PzrLabel( long_x * (maxx - 30), (int) (long_y * 0.5), long_x * 7, long_y * 2, "Search", palette.getColor("#000000"), new Font("Verdana", Font.BOLD, 12)); this.lblSearch.setHorizontalAlignment(SwingConstants.RIGHT); this.cboSearch = new PzrComboBox( long_x * (maxx - 23), (int) (long_y * 0.5), long_x * 10, long_y * 2, "cboSearch"); this.txtSearch = new PzrText( long_x * (maxx - 13), (int) (long_y * 0.5), long_x * 10, long_y * 2, "txtSearch", "", false); this.lblSearch.setFont(new Font("Verdana", Font.PLAIN, 14)); this.cboSearch.setFont(new Font("Verdana", Font.PLAIN, 14)); this.txtSearch.setFont(new Font("Verdana", Font.PLAIN, 14)); this.btnSearchClear = new PzrButton( long_x * (maxx - 3), (int) (long_y * 0.5), long_x * 3, long_y * 2, "btnSearchClear", "", palette.getColor("#DFF2BF"), ""); this.btnSearchClear.setOpaque(false); this.btnSearchClear.setForeground(palette.getColor("#000000")); this.btnSearchClear.repaint("/gui/image/grid_search_clear.png", 32, 32); _D.add(btnGridFirst); _D.add(btnGridPrevious); _D.add(btnGridSet1); _D.add(btnGridSet2); _D.add(btnGridSet3); _D.add(btnGridSet4); _D.add(btnGridSet5); _D.add(btnGridNext); _D.add(btnGridLast); _D.add(btnGridRefresh); _D.add(lblSearch); _D.add(cboSearch); _D.add(txtSearch); _D.add(btnSearchClear); // Show this.setUndecorated(true); this.getRootPane().setWindowDecorationStyle(JRootPane.NONE); this.setLocationRelativeTo(null); this.setModal(true); }
@Override public boolean _setProgress( IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { assertIsDispatchThread(); if (getAppImage() == null) return false; myCurrentProcessId = processId; if (Math.abs(myLastValue - value) < 0.02d) return true; try { int progressHeight = (int) (myAppImage.getHeight() * 0.13); int xInset = (int) (myAppImage.getWidth() * 0.05); int yInset = (int) (myAppImage.getHeight() * 0.15); final int width = myAppImage.getWidth() - xInset * 2; final int y = myAppImage.getHeight() - progressHeight - yInset; Shape rect = new RoundRectangle2D.Double( xInset, y, width, progressHeight, progressHeight, progressHeight); Shape border = new RoundRectangle2D.Double( xInset - 1, y - 1, width + 2, progressHeight + 2, (progressHeight + 2), (progressHeight + 2)); Shape progress = new RoundRectangle2D.Double( xInset + 1, y + 1, (width - 2) * value, progressHeight - 1, (progressHeight - 2), (progressHeight - 1)); AppImage appImg = createAppImage(); final Color brighter = Color.GRAY.brighter().brighter(); final Color backGround = new Color(brighter.getRed(), brighter.getGreen(), brighter.getBlue(), 85); appImg.myG2d.setColor(backGround); appImg.myG2d.fill(rect); final Color color = isOk ? scheme.getOkColor() : scheme.getErrorColor(); final Paint paint = UIUtil.getGradientPaint( xInset + 1, y + 1, color.brighter(), xInset + 1, y + progressHeight - 1, color.darker().darker()); appImg.myG2d.setPaint(paint); appImg.myG2d.fill(progress); appImg.myG2d.setColor(Color.GRAY.darker().darker()); appImg.myG2d.draw(rect); appImg.myG2d.draw(border); setDockIcon(appImg.myImg); myLastValue = value; } catch (Exception e) { LOG.error(e); } finally { myCurrentProcessId = null; } return true; }