Ejemplo n.º 1
0
 public final void paint(LGraphics g) {
   if (!running || isClose()) {
     return;
   }
   if (sleep == 0) {
     if (scrCG == null) {
       return;
     }
     if (scrCG.getBackgroundCG() != null) {
       if (shakeNumber > 0) {
         g.drawImage(
             scrCG.getBackgroundCG(),
             shakeNumber / 2 - LSystem.random.nextInt(shakeNumber),
             shakeNumber / 2 - LSystem.random.nextInt(shakeNumber));
       } else {
         g.drawImage(scrCG.getBackgroundCG(), 0, 0);
       }
     }
     int moveCount = 0;
     for (int i = 0; i < scrCG.getCharas().size(); i++) {
       Chara chara = (Chara) scrCG.getCharas().get(i);
       float value = 1.0f;
       if (chara.next()) {
         value = chara.getNextAlpha();
         moveCount++;
       }
       g.setAlpha(value);
       chara.draw(g);
       g.setAlpha(1.0F);
     }
     drawScreen(g);
     if (desktop != null) {
       desktop.createUI(g);
     }
     if (sprites != null) {
       sprites.createUI(g);
     }
   } else {
     sleep--;
     if (color != null) {
       double alpha = (double) (sleepMax - sleep) / sleepMax;
       if (alpha < 1.0) {
         if (scrCG.getBackgroundCG() != null) {
           g.drawImage(scrCG.getBackgroundCG(), 0, 0);
         }
         g.setAlpha(alpha);
         g.setColor(color);
         g.fillRect(0, 0, getCurrentWidth(), getCurrentHeight());
         g.setAlpha(1.0f);
       }
     }
     if (sleep <= 0) {
       sleep = 0;
       color = null;
     }
   }
 }
Ejemplo n.º 2
0
 public void createUI(LGraphics g, int nx, int ny, int x, int y, int w, int h) {
   if (!visible) {
     return;
   }
   Color oldColor = g.getColor();
   g.translate(nx, ny);
   if (alpha > 0.1 && alpha < 1.0) {
     g.setAlpha(alpha);
     g.setColor(color);
     g.fillRect(x, y, w, h);
     g.setAlpha(1.0F);
   } else {
     g.setColor(color);
     g.fillRect(x, y, w, h);
   }
   g.translate(-nx, -ny);
   g.setColor(oldColor);
 }
Ejemplo n.º 3
0
 public void draw(LGraphics g, int x, int y, int w, int h) {
   switch (style) {
     case 0:
       Color oldColor = g.getColor();
       g.setAntiAlias(true);
       g.setColor(color);
       float alpha = 0.0f;
       int nx = x + w / 2 - (int) r * 4, ny = y + h / 2 - (int) r * 4;
       g.translate(nx, ny);
       for (Iterator it = list.iterator(); it.hasNext(); ) {
         Shape s = (Shape) it.next();
         alpha = isRunning ? alpha + 0.1f : 0.5f;
         g.setAlpha(alpha);
         g.fill(s);
       }
       g.setAntiAlias(false);
       g.setAlpha(1.0F);
       g.translate(-nx, -ny);
       g.setColor(oldColor);
       break;
     case 1:
       g.translate(x, y);
       g.setAntialiasAll(true);
       g.setColor(fill);
       g.drawRect(0, 0, width, height);
       g.setStroke(stroke);
       int sa = angle % 360;
       g.setPaint(border);
       g.drawArc(
           x + (width - paintWidth) / 2,
           y + (height - paintHeight) / 2,
           paintWidth,
           paintHeight,
           sa,
           sa + ANGLE_STEP);
       g.setAntialiasAll(false);
       g.translate(-x, -y);
       break;
   }
 }
Ejemplo n.º 4
0
 public void paintObjects(LGraphics g, int minX, int minY, int maxX, int maxY) {
   if (objects == null) {
     return;
   }
   synchronized (objects) {
     int paintSeq = 0;
     boolean isListener = false;
     Iterator iter = objects.iterator();
     Actor thing = null;
     while (iter.hasNext()) {
       thing = (Actor) iter.next();
       if (!thing.isVisible()) {
         continue;
       }
       isListener = (thing.actorListener != null);
       thing.update(elapsedTime);
       if (isListener) {
         thing.actorListener.update(elapsedTime);
       }
       RectBox rect = thing.getRectBox();
       int actorX = minX + thing.getX();
       int actorY = minY + thing.getY();
       int actorWidth = rect.getWidth();
       int actorHeight = rect.getHeight();
       if (actorX + actorWidth < minX
           || actorX > maxX
           || actorY + actorHeight < minY
           || actorY > maxY) {
         continue;
       }
       LImage actorImage = thing.getImage();
       if (actorImage != null) {
         thing.setLastPaintSeqNum(paintSeq++);
         boolean isBitmapFilter = ImageFilterType.NoneFilter != thing.filterType;
         Image bitmap = actorImage.getBufferedImage();
         if (isBitmapFilter) {
           bitmap = factory.doFilter(bitmap, thing.filterType);
         }
         int rotation = thing.getRotation();
         if (thing.alpha < 1.0) {
           g.setAlpha(thing.alpha);
         }
         if (rotation != 0) {
           double halfWidth = actorImage.getWidth() / 2;
           double halfHeight = actorImage.getHeight() / 2;
           double newWidth = actorX + halfWidth;
           double newHeight = actorY + halfHeight;
           atform.setToIdentity();
           atform.scale(thing.scaleX, thing.scaleY);
           atform.translate(newWidth, newHeight);
           atform.rotate(Math.toRadians(rotation));
           atform.translate(-newWidth, -newHeight);
           atform.translate(actorX, actorY);
           g.drawImage(bitmap, atform);
         } else {
           int width = (int) (actorImage.getWidth() * thing.scaleX);
           int height = (int) (actorImage.getHeight() * thing.scaleY);
           g.drawImage(bitmap, actorX, actorY, width, height);
         }
         if (isBitmapFilter) {
           bitmap.flush();
           bitmap = null;
         }
         if (thing.alpha < 1.0) {
           g.setAlpha(1.0F);
         }
       }
       if (actorX == 0 && actorY == 0) {
         thing.draw(g);
         if (isListener) {
           thing.actorListener.draw(g);
         }
       } else {
         g.translate(actorX, actorY);
         thing.draw(g);
         if (isListener) {
           thing.actorListener.draw(g);
         }
         g.translate(-actorX, -actorY);
       }
     }
   }
 }