/** Draws the histogram labels */ protected void drawHistLabels() { parent.pushStyle(); parent.textMode(MODEL); parent.textFont(font); parent.textSize(fontSize); parent.fill(fontColor); parent.noStroke(); if (type == GPlot.VERTICAL) { if (rotateLabels) { parent.textAlign(RIGHT, CENTER); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i) && plotPoints.getX(i) >= 0 && plotPoints.getX(i) <= dim[0]) { parent.pushMatrix(); parent.translate(plotPoints.getX(i), labelsOffset); parent.rotate(-HALF_PI); parent.text(plotPoints.getLabel(i), 0, 0); parent.popMatrix(); } } } else { parent.textAlign(CENTER, TOP); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i) && plotPoints.getX(i) >= 0 && plotPoints.getX(i) <= dim[0]) { parent.text(plotPoints.getLabel(i), plotPoints.getX(i), labelsOffset); } } } } else { if (rotateLabels) { parent.textAlign(CENTER, BOTTOM); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i) && -plotPoints.getY(i) >= 0 && -plotPoints.getY(i) <= dim[1]) { parent.pushMatrix(); parent.translate(-labelsOffset, plotPoints.getY(i)); parent.rotate(-HALF_PI); parent.text(plotPoints.getLabel(i), 0, 0); parent.popMatrix(); } } } else { parent.textAlign(RIGHT, CENTER); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i) && -plotPoints.getY(i) >= 0 && -plotPoints.getY(i) <= dim[1]) { parent.text(plotPoints.getLabel(i), -labelsOffset, plotPoints.getY(i)); } } } } parent.popStyle(); }
public void hover() { PVector mouse = new PVector(parent.mouseX, parent.mouseY); int[] ponto = getSquare(mouse); if (ponto != null && ponto[QTD] > 0) { parent.textSize(16); parent.text(eixoY + ": " + (int) ponto[0], 200, high() + 16); parent.text(eixoX + ": " + (int) ponto[1], 200, high() + 32); parent.text(eixoZ + ": " + (int) ponto[2], 200, high() + 48); } }
public void draw(int x, int y, int width, int height) { parent.fill(120); parent.textSize(20); parent.text(titulo, startAtX, startAtY - 22); parent.textSize(10); parent.text(eixoX + " x " + eixoY, startAtX, startAtY - 10); parent.textSize(squareSpace / 2); drawYAxis(); drawXAxis(); drawSquares(); }
public void drawXAxis() { for (int i = 0; i < data[0].length; i++) parent.text( "" + (data[0][i][Y_CORD] + 1), startAtX + (i + 1) * squareSpace, startAtY + (data[0][i].length + 3) * squareSpace); }
void drawConsole() { // Draw console parent.stroke(255); parent.fill(0); parent.rect(parent.width - 410, 10, 400, 30); parent.fill(255); parent.text(textBuffer, parent.width - 400, 30); }
public static void staticDisplay(PApplet main, char player, int width, int height) { String name = "Knight"; if (player == Chess.WHITE) { main.stroke(255); main.fill(255); main.ellipse(width, height, 40, 40); main.stroke(0); main.fill(0); main.text(name, width - 15, height + 5); } else { main.stroke(0); main.fill(0); main.ellipse(width, height, 40, 40); main.stroke(255); main.fill(255); main.text(name, width - 15, height + 5); } // end if-else } // end staticDisplay()
public void drawLegend(PApplet pg, int posX, int posY, int length, int mouseX, int mouseY) { this.posX = posX; this.posY = posY; this.length = length; this.pg = pg; // Save previous drawing style pg.pushStyle(); // color filling for (int i = posX; i <= posX + length; i++) { float inter = pg.map(i, posX, posX + length, 0, 1); int c = pg.lerpColor(fromColor, toColor, inter); pg.stroke(c); pg.line(i, posY, i, posY + 25); } // border pg.stroke(0); pg.rect(posX, posY, length, 25, 0); // title pg.fill(0); pg.textAlign(pg.CENTER); pg.text(title, posX + length / 2, posY - 10); // min and max values pg.text(minValue, posX, posY - 10); pg.text(maxValue, posX + length, posY - 10); // corresponding value shown below the color box if (isInLegend(mouseX, mouseY)) { float inter = pg.map((float) mouseX, (float) posX, (float) posX + length, minValue, maxValue); pg.fill(0); pg.text(inter, mouseX, posY + 40); } // Restore previous drawing style pg.popStyle(); }
void display(String l) { // 选择显示坐标轴的方案序号 if (l == "x") { r.scaley(); x0 = r.x0; y0 = r.y0; x1 = r.x1; y1 = r.y1; float textSize = p.abs(y1 - y0); p.textFont(p.createFont("AngsanaNew-BoldItalic", textSize)); p.text(text, x0, y1); } if (l == "y") { r.scalex(); x0 = r.x0; y0 = r.y0; x1 = r.x1; y1 = r.y1; double textSize = p.abs(x1 - x0) / (float) n; p.textFont(p.createFont("AngsanaNew-BoldItalic", textSize)); p.text(text, x0, y1); } }
public void drawSquaresAt(int comeco, int qtd, int x, int y, int squareX, int squareY) { for (int i = 0; i < data.length; i++) { for (int j = comeco; j < comeco + qtd; j++) { int quantidade = data[3 - i][j][QTD]; float cor = 255 - ((float) quantidade / 100) * 255; parent.fill(cor); parent.stroke(cor); int atX = x + (j - comeco) * squareX; int atY = y + i * squareY; parent.rect(atX, atY, atX + squareX, atY + squareY); if (cor > 127) cor = 0; else cor = 255; parent.fill(cor); if (probabilidades) parent.text("" + quantidade + "%", atX + 30, atY + 30); else parent.text("" + quantidade, atX + 30, atY + 30); // parent.text("" + data[3 - i][j][QTD], startAtX + squareSpace + j * squareSpace, // startAtY + (i + 1) * squareSpace + squareSpace); } } }
/** * Draws the control where if should be drawn * * @param p */ public void draw() { p.pushMatrix(); p.pushStyle(); p.translate(x, y); p.fill(textColor); // AlignUtils.positionText(p, width, height, xAlign, yAlign); p.textAlign(PApplet.LEFT, PApplet.CENTER); p.text(name, 0, height / 2); // p.text(name, 0, 0); p.popStyle(); p.popMatrix(); }
@Override public void display() { if (isDisplay) { context.fill(0, 80); // rect(xpos, ypos, width, width); context.fill(196, 196, 196, 80); context.ellipse(xpos + width / 2, ypos + width / 2, width, width); context.fill(255); context.ellipse(xpos + width / 2, ypos + width / 2, width / 2, width / 2); if (isSelected) { context.fill(255, 196, 13); context.ellipse(xpos + width / 2, ypos + width / 2, width / 2, width / 2); } context.fill(255); context.textSize(10); context.text("Bus Number", xpos - width, ypos + 3 * height / 2); } }
public void drawSquares() { for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { float cor = 255 - ((float) data[3 - i][j][QTD] / 100) * 255; parent.fill(cor); parent.stroke(cor); parent.rect( startAtX + squareSpace + j * squareSpace, startAtY + (i + 1) * squareSpace, squareSpace, squareSpace); if (cor > 127) cor = 0; else cor = 255; parent.fill(cor); parent.text( "" + data[3 - i][j][QTD], startAtX + squareSpace + j * squareSpace, startAtY + (i + 1) * squareSpace + squareSpace); } } }
public void drawYAxis() { for (int i = 0; i < data.length; i++) parent.text("" + (data.length - i), startAtX, startAtY + (i + 2) * squareSpace); }
public static void highScoreScreen() { if (highscore) { int bx = -15; int by = 830; parent.image(topShooters, 0, 0); if (topshootCounter <= 30) { topshootCounter = topshootCounter + 1; parent.image(topShooters2, 0, 0); } if (topshootCounter <= 60) { topshootCounter = topshootCounter + 1; parent.image(topShooters3, 0, 0); } if (topshootCounter <= 90) { topshootCounter = topshootCounter + 1; parent.image(topShooters4, 0, 0); } if (topshootCounter <= 120) { topshootCounter = topshootCounter + 1; parent.image(topShooters5, 0, 0); } if (topshootCounter <= 120) { topshootCounter = topshootCounter + 1; parent.image(topShooters6, 0, 0); } if (topshootCounter <= 130) { topshootCounter = topshootCounter + 1; parent.image(topShooters, 0, 0); } if (topshootCounter <= 140) { topshootCounter = topshootCounter + 1; parent.image(topShooters, 0, 0); } if (topshootCounter <= 150) { topshootCounter = topshootCounter + 1; parent.image(topShooters6, 0, 0); } else { topshootCounter = 0; parent.image(topShooters, 0, 0); } parent.textSize(80); parent.fill(255, 215, 0); parent.text(" 1. " + scoreList.get(0), 285, 350); parent.fill(240, 230, 140); parent.text(" 2. " + scoreList.get(1), 285, 450); parent.fill(255, 255, 255); parent.text(" 3. " + scoreList.get(2), 285, 550); // backbutton and rollover parent.image(backbutton, bx, by); if (parent.mouseX > bx + 60 && parent.mouseX < bx + 210 && parent.mouseY > by + 20 && parent.mouseY < by + 60) { parent.image(backbutton2, bx, by); if (parent.mousePressed) { highscore = false; splash = true; } } } }
public void drawText(int tx, int ty, String message) { p.text(message, tx, ty); }
public static void settingsScreen() { if (settings) { int bx = -15; int by = 830; // controls parent.image(controlsline, 45, 0); parent.image(moverl, 105, 100); parent.image(spaceShoot, 50, 150); parent.image(pauseimg, 145, 200); parent.image(buttonR, 500, 100); parent.image(buttonQ, 500, 155); parent.image(buttonM, 500, 210); parent.textSize(40); parent.text("Movement", 250, 150); parent.text("Shoot", 250, 200); parent.text("Pause", 250, 250); parent.text("Reset", 590, 150); parent.text("Quit", 590, 210); parent.text("Menu", 590, 265); // bullets parent.image(bulletsline, 45, 300); if (fireballCounter <= 10) { // firebullet animation fireballCounter = fireballCounter + 1; parent.image(bullet1, 270, 420); } else if (fireballCounter <= 15) { fireballCounter = fireballCounter + 1; parent.image(bullet2, 270, 420); } else if (fireballCounter <= 20) { fireballCounter = fireballCounter + 1; parent.image(bullet3, 270, 420); } else if (fireballCounter <= 25) { fireballCounter = fireballCounter + 1; parent.image(bullet4, 270, 420); } else { fireballCounter = 0; parent.image(bullet1, 270, 420); } parent.textSize(20); parent.text("Fireball", 250, 480); if (parent.mouseX > 230 && parent.mouseX < 320 && parent.mouseY > 420 && parent.mouseY < 500) { if (parent.mousePressed) { fireVisualToggle = true; waterVisualToggle = false; regularVisualToggle = false; BulletsClass.fire = true; BulletsClass.water = false; BulletsClass.regular = false; } } if (fireVisualToggle) { parent.textSize(35); parent.text("^", 275, 510); } // waterbullet animation if (waterballCounter <= 10) { waterballCounter = waterballCounter + 1; parent.image(waterbullet1, 430, 420); } else if (waterballCounter <= 15) { waterballCounter = waterballCounter + 1; parent.image(waterbullet2, 430, 420); } else if (waterballCounter <= 20) { waterballCounter = waterballCounter + 1; parent.image(waterbullet3, 430, 420); } else if (waterballCounter <= 25) { waterballCounter = waterballCounter + 1; parent.image(waterbullet4, 430, 420); } else { waterballCounter = 0; parent.image(waterbullet1, 430, 420); } parent.textSize(20); parent.text("Waterball", 400, 480); if (parent.mouseX > 400 && parent.mouseX < 510 && parent.mouseY > 420 && parent.mouseY < 485) { if (parent.mousePressed) { fireVisualToggle = false; waterVisualToggle = true; regularVisualToggle = false; BulletsClass.water = true; BulletsClass.fire = false; BulletsClass.regular = false; } } if (waterVisualToggle) { parent.textSize(35); parent.text("^", 440, 510); } // regular bullet parent.rect(130, 430, 5, 20); parent.textSize(20); parent.text("Regular", 100, 480); if (parent.mouseX > 100 && parent.mouseX < 180 && parent.mouseY > 420 && parent.mouseY < 485) { parent.image(backbutton2, bx, by); if (parent.mousePressed) { fireVisualToggle = false; waterVisualToggle = false; regularVisualToggle = true; BulletsClass.water = false; BulletsClass.fire = false; BulletsClass.regular = true; } } if (regularVisualToggle) { parent.textSize(35); parent.text("^", 125, 510); } // difficulty parent.image(difficultyline, 45, 520); int easyx = 50; int easyy = 600; parent.image(easy, easyx, easyy); if (parent.mouseX > easyx + 16 && parent.mouseX < easyx + 210 && parent.mouseY > easyy + 20 && parent.mouseY < easyy + 180) { parent.image(easy2, easyx, easyy); if (parent.mousePressed) { easyToggle = true; mediumToggle = false; hardToggle = false; } } int mediumx = 250; int mediumy = 600; parent.image(medium, mediumx, mediumy); if (parent.mouseX > mediumx + 16 && parent.mouseX < mediumx + 210 && parent.mouseY > mediumy + 20 && parent.mouseY < mediumy + 180) { parent.image(medium2, mediumx, mediumy); if (parent.mousePressed) { easyToggle = false; mediumToggle = true; hardToggle = false; } } int hardx = 450; int hardy = 600; parent.image(hard, hardx, hardy); if (parent.mouseX > hardx + 16 && parent.mouseX < hardx + 210 && parent.mouseY > hardy + 20 && parent.mouseY < hardy + 180) { parent.image(hard2, hardx, hardy); if (parent.mousePressed) { easyToggle = false; mediumToggle = false; hardToggle = true; } } if (easyToggle) { parent.image(easy2, easyx, easyy); AlienClass.xspeed1 = -1; AlienClass.alienShootSpeed = 140; } if (mediumToggle) { parent.image(medium2, mediumx, mediumy); AlienClass.xspeed1 = -3; AlienClass.alienShootSpeed = 100; } if (hardToggle) { parent.image(hard2, hardx, hardy); AlienClass.xspeed1 = -4; AlienClass.alienShootSpeed = 40; } // backbutton and rollover parent.image(backbutton, bx, by); if (parent.mouseX > bx + 60 && parent.mouseX < bx + 210 && parent.mouseY > by + 20 && parent.mouseY < by + 60) { parent.image(backbutton2, bx, by); if (parent.mousePressed) { settings = false; splash = true; } } } }
public void hover(float w) { parent.textSize(16); parent.text(eixoW + ": " + w, 200, high() + 64); }
public static void drawVisuals() { // play button int pbx = 300; int pby = 400; // high score button int hx = 230; int hy = 500; // settings button int sx = 270; int sy = 600; // quit button int qx = 230; int qy = 700; // back button int bx = 50; int by = 50; if (splash) { // LOGO counter = counter + 1; if (counter < 10) parent.image(splash1, 115, 100); else if (counter < 20) parent.image(splash2, 115, 100); else if (counter < 30) parent.image(splash3, 115, 100); else if (counter < 40) parent.image(splash2, 115, 100); else if (counter < 50) parent.image(splash1, 115, 100); else { counter = 0; parent.image(splash1, 115, 100); } // MENU BUTTONS------------------------- // PLAY BUTTON parent.image(playbutton, pbx, pby); if (parent.mouseX > pbx && parent.mouseX < pbx + 200 && parent.mouseY > pby && parent.mouseY < pby + 55) { parent.image(playbutton2, pbx, pby); if (parent.mousePressed) { if (mainClass.splash) { mainClass.alive = true; mainClass.splash = false; } } } // SETTING BUTTON parent.image(settingbutton, sx, sy); if (parent.mouseX > sx && parent.mouseX < sx + 250 && parent.mouseY > sy && parent.mouseY < sy + 55) { parent.image(settingbutton2, sx, sy); if (parent.mousePressed) { splash = false; settings = true; } } // HIGHSCORE BUTTON parent.image(highscorebutton, hx, hy); if (parent.mouseX > hx && parent.mouseX < hx + 320 && parent.mouseY > hy && parent.mouseY < hy + 55) { parent.image(highscorebutton2, hx, hy); if (parent.mousePressed) { splash = false; highscore = true; } } // QUIT BUTTON parent.image(quitbutton, qx, qy); if (parent.mouseX > qx + 120 && parent.mouseX < qx + 230 && parent.mouseY > qy + 15 && parent.mouseY < qy + 55) { parent.image(quitbutton2, qx, qy); if (parent.mousePressed) { parent.exit(); } } parent.textSize(12); parent.text("v1.18 - Tallah Khan-14017609 - Manchester Metropolitan University", 205, 880); } }