Package ch.sahits.game.graphic.display.util

Examples of ch.sahits.game.graphic.display.util.NamedPolygon


        g2d.drawGlyphVector(gv, x, y);
        // Amount available
       
        // Buy button
        g2d.drawImage(waxSeal, xBuy,y-(int)(positions.lineHeight*0.8), null);
        NamedPolygon polygon = new NamedPolygon(ware.name()+"Buy");
        // The positions of the polygons must be global
        polygon.addPoint(positions.xBuy, topLeft.y+y-(int)(positions.lineHeight*0.8));
        polygon.addPoint(positions.xBuy+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
        polygon.addPoint(positions.xBuy+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
        polygon.addPoint(positions.xBuy, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
        polygons.add(polygon, new City2ShipAction(ware));
       
        // Sell button
        g2d.drawImage(waxSeal, xSell,y-(int)(positions.lineHeight*0.8), null);
        polygon = new NamedPolygon(ware.name()+"Sell");
        polygon.addPoint(positions.xSell, topLeft.y+y-(int)(positions.lineHeight*0.8));
        polygon.addPoint(positions.xSell+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
        polygon.addPoint(positions.xSell+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
        polygon.addPoint(positions.xSell, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
        polygons.add(polygon, new Ship2CityAction(ware));
      }
      // Footer buttons
      y = bg.getHeight()-getInset().bottom-positions.lineHeight;
      x = getInset().left+30;
      int footerWidth = bg.getWidth()-getInset().left-getInset().right-2*30;
      // 1 item
      g2d.setColor(new Color(0xEA,0xC1,0x17)); // Gold
      NamedPolygon polygon;
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      polygon = new NamedPolygon("One");
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      footerPolygons.add(polygon, new TransferAmountChangeAction(ETransferAmount.ONE));
      gv = OpenPatricianPainter.createGlyphVector(g2d, "1", 18);
      int xPadding = ImageUtil.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y);
      x += footerWidth/4;
      // 5 items
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      polygon = new NamedPolygon("five");
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      footerPolygons.add(polygon, new TransferAmountChangeAction(ETransferAmount.FIVE));
      gv = OpenPatricianPainter.createGlyphVector(g2d, "5", 18);
      xPadding = ImageUtil.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y); // centeralign
      x += footerWidth/4;
      // Max item
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      polygon = new NamedPolygon("Max");
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      footerPolygons.add(polygon, new TransferAmountChangeAction(ETransferAmount.MAX));
      gv = OpenPatricianPainter.createGlyphVector(g2d, "Max", 18); //externalize
      xPadding = ImageUtil.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y); // centeralign
      x += footerWidth/4;
      // close
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      polygon = new NamedPolygon("Close");
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      footerPolygons.add(polygon, new CloseAction(this));
      gv = OpenPatricianPainter.createGlyphVector(g2d, "X", 18);
      xPadding = ImageUtil.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y); // centeralign

View Full Code Here


   * Setting the positions of the polygons on the screen
   */
  private void initPortPolygons(double scale,Rectangle bounds) {
    // TODO implement PolygonLoader
    OffsetCalculator offsetter = new OffsetCalculator(getBounds().x+bounds.x, getBounds().y+bounds.y); // top left corner of this view plus any black borders
    NamedPolygon poly = new NamedPolygon(polyNames[0]);
    poly.addPoint(offsetter.computeXOffset(508, scale), offsetter.computeYOffset(678, scale));
    poly.addPoint(offsetter.computeXOffset(574, scale), offsetter.computeYOffset(520, scale));
    poly.addPoint(offsetter.computeXOffset(534, scale), offsetter.computeYOffset(546, scale));
    poly.addPoint(offsetter.computeXOffset(736, scale), offsetter.computeYOffset(586, scale));
    poly.addPoint(offsetter.computeXOffset(702, scale), offsetter.computeYOffset(672, scale));
    poly.addPoint(offsetter.computeXOffset(786, scale), offsetter.computeYOffset(758, scale));
    poly.addPoint(offsetter.computeXOffset(526, scale), offsetter.computeYOffset(756, scale));
    int meanY = (poly.ypoints[1] + poly.ypoints[5]) / 2;
    portPolygons.put(meanY, poly); // maybe we should use meanX instead
  }
View Full Code Here

  /**
   * Setting the positions of the polygons on the screen
   */
  private void initStartPolygons() {
    // TODO implement PolygonLoader
    NamedPolygon poly = new NamedPolygon(names[TEXT_FOCUS_NEW]);
    poly.addPoint(offsetter.computeXOffset(590),
        offsetter.computeYOffset(38));
    poly.addPoint(offsetter.computeXOffset(662),
        offsetter.computeYOffset(45));
    poly.addPoint(offsetter.computeXOffset(654),
        offsetter.computeYOffset(74));
    poly.addPoint(offsetter.computeXOffset(585),
        offsetter.computeYOffset(65));
    int meanY = (poly.ypoints[0] + poly.ypoints[3]) / 2;
    polygons.put(meanY, poly);
    poly = new NamedPolygon(names[TEXT_FOCUS_LOAD]);
    poly.addPoint(offsetter.computeXOffset(565),
        offsetter.computeYOffset(91));
    poly.addPoint(offsetter.computeXOffset(656),
        offsetter.computeYOffset(110));
    poly.addPoint(offsetter.computeXOffset(649),
        offsetter.computeYOffset(148));
    poly.addPoint(offsetter.computeXOffset(552),
        offsetter.computeYOffset(138));
    meanY = (poly.ypoints[0] + poly.ypoints[3]) / 2;
    polygons.put(meanY, poly);
    poly = new NamedPolygon(names[TEXT_FOCUS_OPTIONS]);
    poly.addPoint(offsetter.computeXOffset(543),
        offsetter.computeYOffset(162));
    poly.addPoint(offsetter.computeXOffset(657),
        offsetter.computeYOffset(193));
    poly.addPoint(offsetter.computeXOffset(648),
        offsetter.computeYOffset(233));
    poly.addPoint(offsetter.computeXOffset(537),
        offsetter.computeYOffset(217));
    meanY = (poly.ypoints[0] + poly.ypoints[3]) / 2;
    polygons.put(meanY, poly);
    poly = new NamedPolygon(names[TEXT_FOCUS_CREDITS]);
    poly.addPoint(offsetter.computeXOffset(501),
        offsetter.computeYOffset(252));
    poly.addPoint(offsetter.computeXOffset(619),
        offsetter.computeYOffset(285));
    poly.addPoint(offsetter.computeXOffset(603),
        offsetter.computeYOffset(324));
    poly.addPoint(offsetter.computeXOffset(490),
        offsetter.computeYOffset(309));
    meanY = (poly.ypoints[0] + poly.ypoints[3]) / 2;
    polygons.put(meanY, poly);
    poly = new NamedPolygon(names[TEXT_FOCUS_HISTORY]);
    poly.addPoint(offsetter.computeXOffset(459),
        offsetter.computeYOffset(325));
    poly.addPoint(offsetter.computeXOffset(587),
        offsetter.computeYOffset(365));
    poly.addPoint(offsetter.computeXOffset(574),
        offsetter.computeYOffset(422));
    poly.addPoint(offsetter.computeXOffset(423),
        offsetter.computeYOffset(389));
    meanY = (poly.ypoints[0] + poly.ypoints[3]) / 2;
    polygons.put(meanY, poly);
    poly = new NamedPolygon(names[TEXT_FOCUS_BACK]);
    poly.addPoint(offsetter.computeXOffset(392),offsetter.computeYOffset(397));
    poly.addPoint(offsetter.computeXOffset(433),offsetter.computeYOffset(408));
    poly.addPoint(offsetter.computeXOffset(427),offsetter.computeYOffset(426));
    poly.addPoint(offsetter.computeXOffset(385),offsetter.computeYOffset(416));
    meanY = (poly.ypoints[0] + poly.ypoints[3]) / 2;
    polygons.put(meanY, poly);
    poly = new NamedPolygon(names[TEXT_FOCUS_NEXT]);
    poly.addPoint(offsetter.computeXOffset(854),offsetter.computeYOffset(468));
    poly.addPoint(offsetter.computeXOffset(913),offsetter.computeYOffset(484));
    poly.addPoint(offsetter.computeXOffset(913),offsetter.computeYOffset(512));
    poly.addPoint(offsetter.computeXOffset(858),offsetter.computeYOffset(495));
    meanY = (poly.ypoints[0] + poly.ypoints[3]) / 2;
    polygons.put(meanY, poly);
  }
View Full Code Here

TOP

Related Classes of ch.sahits.game.graphic.display.util.NamedPolygon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.