/** Check weather this imageTask has cache Drawable data. */ public boolean queryCache(ImageTask imageTask, CubeImageView imageView) { if (null == mImageProvider) { return false; } BitmapDrawable drawable = mImageProvider.getBitmapFromMemCache(imageTask); if (imageTask.getStatistics() != null) { imageTask.getStatistics().s0_afterCheckMemoryCache(drawable != null); } if (drawable == null) { return false; } if (DEBUG) { CLog.d( LOG_TAG, MSG_HIT_CACHE, imageTask, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); } imageTask.addImageView(imageView); imageTask.onLoadTaskFinish(drawable, mImageLoadHandler); return true; }
@TargetApi(16) @SuppressWarnings("deprecation") public static void setPosterBackground(ImageView background, String posterPath, Context context) { if (AndroidUtils.isJellyBeanOrHigher()) { background.setImageAlpha(30); } else { background.setAlpha(30); } ImageProvider.getInstance(context).loadImage(background, posterPath, false); }
private void paintCountDown(Graphics2D g) { if (number3) { g.drawImage(ImageProvider.getNumber3(), (dim.width / 2) - 100, (dim.height / 2) - 100, null); } if (number2) { g.drawImage(ImageProvider.getNumber2(), (dim.width / 2) - 100, (dim.height / 2) - 100, null); } if (number1) { g.drawImage(ImageProvider.getNumber1(), (dim.width / 2) - 100, (dim.height / 2) - 100, null); } if (go) { g.drawImage(ImageProvider.getGo(), (dim.width / 2) - 100, (dim.height / 2) - 100, null); } }
private void paintPanelGame(Graphics2D g) { g.drawImage(ImageProvider.getPanelGame(), 0, 0, null); Font font = new Font("ARIAL", 50, 40); g.setFont(font); g.setColor(Color.BLACK); g.drawString("Track", 40, 40); g.drawString(nameTrack, 40, 90); g.drawString("Km/h " + (int) (game.getWorld().getCar().getSpeed() * 50), 480, 90); g.drawString( (int) (game.getCarManagerHuman().getCheckpoints().getActualLaps()) + "/" + game.getCarManagerHuman().getCheckpoints().getTotalLaps() + " Laps", 480, 40); g.drawString( "Time " + actualCalendar.get(Calendar.MINUTE) + ":" + actualCalendar.get(Calendar.SECOND) + ":" + actualCalendar.get(Calendar.MILLISECOND), 700, 90); GregorianCalendar tmpCalendar = new GregorianCalendar(); if (recordTrack > 0) { tmpCalendar.setTimeInMillis(recordTrack); g.drawString( "Best " + tmpCalendar.get(Calendar.MINUTE) + ":" + tmpCalendar.get(Calendar.SECOND) + ":" + tmpCalendar.get(Calendar.MILLISECOND), 700, 40); } else { g.drawString("Best --:--:--", 700, 40); } }
@Override public void mouseDragged(MouseEvent e) { Cursor cursor; Toolkit toolkit = getToolkit(); Point cursorHotSpot = new Point(15, 15); if (matchManager .getPhysicsBallMovement() .checkThatThereAreNoOverlappingBalls(matchManager.getBalls())) cursor = toolkit.createCustomCursor(ImageProvider.getDivietoPointer(), cursorHotSpot, "wrong"); else cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); setCursor(cursor); if (matchManager .getPhysicsBallMovement() .checkThatTheBallDoesNotExceedTheEdgesOfTheTable( e.getX(), e.getY(), matchManager.getTable())) { matchManager.setXMouse(e.getX()); matchManager.setYMouse(e.getY()); this.repaint(); } }
private void paintCar(Graphics2D g) { Graphics2D graphics2d = (Graphics2D) g.create(); graphics2d.rotate( game.getWorld().getCar().getAngle(), (((game.getWorld().getCar().getX3() - game.getWorld().getCar().getX1()) / 3) + game.getWorld().getCar().getX1() + I), (((game.getWorld().getCar().getY2() - game.getWorld().getCar().getY1()) / 2) + game.getWorld().getCar().getY1() + J)); graphics2d.drawImage( ImageProvider.getCar(), (int) game.getWorld().getCar().getX1() + I, (int) game.getWorld().getCar().getY1() + J, null); Graphics2D graphics2d2 = (Graphics2D) g.create(); graphics2d2.rotate( game.getWorld().getCar2().getAngle(), (((game.getWorld().getCar2().getX3() - game.getWorld().getCar2().getX1()) / 3) + game.getWorld().getCar2().getX1() + I), (((game.getWorld().getCar2().getY2() - game.getWorld().getCar2().getY1()) / 2) + game.getWorld().getCar2().getY1() + J)); graphics2d2.drawImage( ImageProvider.getCar2(), (int) game.getWorld().getCar2().getX1() + I, (int) game.getWorld().getCar2().getY1() + J, null); Graphics2D graphics2d3 = (Graphics2D) g.create(); graphics2d3.rotate( game.getWorld().getCar3().getAngle(), (((game.getWorld().getCar3().getX3() - game.getWorld().getCar3().getX1()) / 3) + game.getWorld().getCar3().getX1() + I), (((game.getWorld().getCar3().getY2() - game.getWorld().getCar3().getY1()) / 2) + game.getWorld().getCar3().getY1() + J)); graphics2d3.drawImage( ImageProvider.getCar3(), (int) game.getWorld().getCar3().getX1() + I, (int) game.getWorld().getCar3().getY1() + J, null); Graphics2D graphics2d4 = (Graphics2D) g.create(); graphics2d4.rotate( game.getWorld().getCar4().getAngle(), (((game.getWorld().getCar4().getX3() - game.getWorld().getCar4().getX1()) / 3) + game.getWorld().getCar4().getX1() + I), (((game.getWorld().getCar4().getY2() - game.getWorld().getCar4().getY1()) / 2) + game.getWorld().getCar4().getY1() + J)); graphics2d4.drawImage( ImageProvider.getCar4(), (int) game.getWorld().getCar4().getX1() + I, (int) game.getWorld().getCar4().getY1() + J, null); }
private void paintMiniWorld(final Graphics g) { int size = 40; int I = dim.width - size * World.Y_MATRIX_STRING; int J = 0; for (int i = 0; i < World.X_MATRIX_STRING; i++) { for (int j = 0; j < World.Y_MATRIX_STRING; j++) { if ("horizontal".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMinihorizontal(), j * size + I, i * size + J, null); } if ("vertical".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMinivertical(), j * size + I, i * size + J, null); } if ("curveleftup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMiniLeftup(), j * size + I, i * size + J, null); } if ("curveleftdown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMiniLeftdown(), j * size + I, i * size + J, null); } if ("curverightup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMiniRigthup(), j * size + I, i * size + J, null); } if ("curverightdown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMiniRightdown(), j * size + I, i * size + J, null); } if ("grass".equals(game.getWorld().getMatrixString()[i][j])) { // g.drawImage(ImageProvider.getMinigrass(), // j*size+I,i*size+J, null); } if ("starthorizontalright".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMinistarthorizontal(), j * size + I, i * size + J, null); } if ("starthorizontalleft".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMinistarthorizontal(), j * size + I, i * size + J, null); } if ("startverticalup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMinistartvertical(), j * size + I, i * size + J, null); } if ("startverticaldown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage(ImageProvider.getMinistartvertical(), j * size + I, i * size + J, null); } } } g.setColor(Color.RED); g.fillRect( (int) (game.getWorld().getCar2().getX1() / ((double) AbstractBlockRoadObject.getSize() / (double) size) + I), (int) (game.getWorld().getCar2().getY1() / ((double) AbstractBlockRoadObject.getSize() / (double) size) + J), 6, 6); g.setColor(Color.YELLOW); g.fillRect( (int) (game.getWorld().getCar().getX1() / ((double) AbstractBlockRoadObject.getSize() / (double) size) + I), (int) (game.getWorld().getCar().getY1() / ((double) AbstractBlockRoadObject.getSize() / (double) size) + J), 6, 6); }
private void paintCornice(final Graphics g) { int x = I - AbstractBlockRoadObject.getSize(); int y = J - AbstractBlockRoadObject.getSize(); g.drawImage(ImageProvider.getBoardEdgeUpLeft(), x, y, null); g.drawImage( ImageProvider.getBoardEdgeDownRight(), World.Y_MATRIX_STRING * AbstractBlockRoadObject.getSize() + x + AbstractBlockRoadObject.getSize(), World.X_MATRIX_STRING * AbstractBlockRoadObject.getSize() + y + AbstractBlockRoadObject.getSize(), null); g.drawImage( ImageProvider.getBoardEdgeUpRight(), World.Y_MATRIX_STRING * AbstractBlockRoadObject.getSize() + x + AbstractBlockRoadObject.getSize(), y, null); g.drawImage( ImageProvider.getBoardEdgeDownLeft(), x, World.X_MATRIX_STRING * AbstractBlockRoadObject.getSize() + y + AbstractBlockRoadObject.getSize(), null); for (int i = 0; i < World.Y_MATRIX_STRING; i++) { g.drawImage( ImageProvider.getBoardHigh(), i * AbstractBlockRoadObject.getSize() + x + AbstractBlockRoadObject.getSize(), 0 + y, null); g.drawImage( ImageProvider.getBoardDown(), i * AbstractBlockRoadObject.getSize() + x + AbstractBlockRoadObject.getSize(), (World.X_MATRIX_STRING + 1) * AbstractBlockRoadObject.getSize() + y, null); } for (int i = 0; i < World.X_MATRIX_STRING; i++) { g.drawImage( ImageProvider.getBoardLeft(), 0 + x, i * AbstractBlockRoadObject.getSize() + y + AbstractBlockRoadObject.getSize(), null); g.drawImage( ImageProvider.getBoardRight(), (World.Y_MATRIX_STRING + 1) * AbstractBlockRoadObject.getSize() + x, i * AbstractBlockRoadObject.getSize() + y + AbstractBlockRoadObject.getSize(), null); } }
private void paintWorldImage(final Graphics g) { // moveCamera(); for (int i = 0; i < World.X_MATRIX_STRING; i++) { for (int j = 0; j < World.Y_MATRIX_STRING; j++) { if ("horizontal".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getHorizontal(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("vertical".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getVertical(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("curveleftup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getUpLeft(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("curveleftdown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getDownLeft(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("curverightup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getUpRigth(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("curverightdown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getDownRight(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("grass".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getGrass(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("starthorizontalright".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getStart(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("starthorizontalleft".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getStart(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("startverticalup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getStartVertical(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("startverticaldown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getStartVertical(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } } } }
@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()); } }
/** flush un-cached image to disk */ public void flushFileCache() { if (mImageProvider != null) { mImageProvider.flushFileCache(); } }