id
stringlengths
36
36
text
stringlengths
1
1.25M
9b12509d-56a1-44cf-9b4d-d7a4c94f2585
public void write(final String id, final BufferedImage tile, final int x, final int y) throws IOException { ImageIO.write(tile, fileType, new File(filenameFor(id, x, y))); }
e360654d-05a9-4e4e-9c78-cdd50aee94b5
private String filenameFor(String id, int x, int y) { return path + File.separator + id + "_" + x + "_" + y + "." + fileType; }
02b30089-6cb7-4310-b7cf-30423bc641d1
public static void setFileType(String fileType) { Writer.fileType = fileType; }
f62af032-0ed6-4093-b0d6-8c9d53b915f4
public OpenSlideImage fetch(String target) throws IOException { if (target.startsWith("http://") || target.startsWith("https://")) { return fetch(new URL(target)); } else { return new OpenSlideImage(target); } }
0be5f8ea-5d97-49d0-ac07-4fe78281cf1e
public OpenSlideImage fetch(URL url) throws IOException { String[] urlParts = url.getFile().split("/"); String filename = urlParts[urlParts.length - 1]; File target = new File(downloadPath + filename); // Only download the file if we dont have it (Note, doesnt check validity) i...
5cd394d5-35a0-45e5-a372-75433ec607d8
public Map<String, OpenSlideImage> fetch(final Collection<String> targets) { Map<String, OpenSlideImage> map = new HashMap<>(); for (String target : targets) { try { map.put(target, fetch(target)); } catch (IOException e) { System.err.println("Fail...
264a81e0-c6cf-4fec-ab6f-55e0094a7b11
public void updateSlides(Patient patient, SlideIndex index) { final Map<String, OpenSlideImage> slides = getSlides(patient, index); for (Map.Entry<String, OpenSlideImage> slideEntry : slides.entrySet()) { patient.addSlide(slideEntry.getKey(), slideEntry.getValue()); } }
451a0032-1bdf-444d-b117-a616919c1aca
public Map<String, OpenSlideImage> getSlides(Patient patient, SlideIndex index) { Collection<String> slideUrls = index.getSlideUrls(patient); return fetch(slideUrls); }
9d5c614a-c6fb-47c6-aa1c-0847b2cac667
public static void setDownloadPath(String downloadPath) { File dir = new File(downloadPath); if (!dir.exists()) { try { Files.createDirectory(dir.toPath()); } catch (IOException e) { System.err.println("Failed to create " + dir + " for slides becau...
315a7306-0a5f-43fd-8d52-61ca609863cf
public Tiler(int tileWidth, int tileHeight, double zoom) { this.tileWidth = tileWidth; this.tileHeight = tileHeight; this.zoom = zoom; }
b101f4de-9d81-4fd2-b11e-5b776ad2d1ac
public Map<Point, BufferedImage> tile(OpenSlideImage slide) { Map<Point, BufferedImage> map = new HashMap<>(); for (int y = 0; y < slide.getHeight(); y += tileHeight) { for (int x = 0; x < slide.getWidth(); x += tileWidth) { try { BufferedImage tile = slid...
05b30ab8-2bf3-452f-b1b5-14592ce8d647
public void setup(){ //ResourceAvailability size(500,500); f = createFont ("Arial", 16,true); }
564ed7f9-7bbc-4a33-9709-675f21ee1feb
public void draw() { background(255); int indent = 25; textFont(f); fill(0); //display text("If I could have any career I would choose ____", indent,40); text(typing, indent,90); text(saved, indent,130); }
f2b38aed-5d8f-4755-a49a-30ab33643bfb
public void keyPressed() { if (key == '\n') { saved = typing; // A String can be cleared by setting it equal to "" typing = ""; } else { // otherwise, concatenate the String // Each character typed by the user is added to the end of the string variable typing = typing + key; } }
5e95d8dc-fa0b-4c14-8744-861133730f5d
public static void AddToOption(String User, String OptionName, String OptionCareer) { System.out.println("Hello World."); //String X =""; JOptionPane.showMessageDialog(null, "Do you want to add "+ OptionName+" to your option list"); //if //int test; }
b3c96753-4027-4725-82c2-007cc68753d5
public Chain(int len, Point l, Point r, boolean dl, boolean dr) { length = len; left = l; right = r; deadLeft = dl; deadRight = dr; }
9b33e44f-7606-49b5-ac27-2848add85200
public String toString() { return "Left: (" + left.x + ", " + left.y + "), Right: (" + right.x + ", " + right.y + "), Length : " + length + ", " + deadLeft + ", " + deadRight; }
edd71356-e70a-46e3-8b1d-f2a301005e37
public PointWrapper(int score, Point move){ this.score = score; this.move = move; }
dfe356bc-08e6-475e-8950-09bcb35f53a8
@Override public int compareTo(PointWrapper p) { return score - p.score; }
a63fe6fa-0e74-454f-af5d-53c27c4b399e
public ArrayList<Point> generateRelevantMoves(BoardModel state) { ArrayList<Point> rMoves = new ArrayList<Point>(); if(!boardMoves.containsKey(state.hashCode())){ if(state.gravityEnabled()){ for(int i = 0; i < state.getWidth(); i++){ for(int j = 0; j < state.getHeight(); j++){ if(state.getSpace(i,...
2905504a-5d7c-430b-bcc3-dd0632dd56d8
public void updateMoveOrdering(ArrayList<PointWrapper> moves, BoardModel state){ TreeSet<PointWrapper> sorter = new TreeSet<PointWrapper>(); ArrayList<Point> sorted = new ArrayList<Point>(); for(PointWrapper move:moves){ sorter.add(move); } for(PointWrapper move:sorter){ sorted.add(move.move); } for...
cf231e82-300b-4ea5-8d65-4dc5c49ac9e5
public static void main(String[] args) { // Pass width and height of the game board // Also passes the existence of a second player // initializes the pictures for the game try { Fence.img = ImageIO.read(new File("res/img/Kuszmaul.jpg")); GridPanel.lab = ImageIO.read(new File("res/img/EverythingIsTyler.pn...
4e2c6215-ee73-4bc2-8f2e-2b34d86b1c19
public Cell[][] getGrid() {return grid;}
8a006e98-bd2b-48a2-8211-4ac0d8493415
public GridPanel(boolean twoPlayer, int width, int height, Gui gui) { this.height = height; this.width = width; this.gui = gui; this.p2 = twoPlayer; this.h = height-2; this.w = width-2; grid = new Cell[width][height]; initAllCells(); }
aa4a9bbe-925c-493d-ab4f-90b4ac739a26
public Gui getGui() { return this.gui; }
c2025a5f-3432-4619-913a-b03b109c3a38
public int getH() { return this.height; }
fbb7010e-2ac9-4307-b728-30ca71904936
public int getW() { return this.width; }
b111d6e7-9d61-47e4-84a7-cf6b7dcf7ed8
public Cell getCell(int x, int y) { return grid[x][y]; }
2cca31a1-ae8d-49fc-ac67-e3981534025c
public void initAllCells() { initCells(); initBorders(); initInsideFences(); initEnemies(); initPlayer(1); if(p2) initPlayer(2); }
7f64b39a-6e5a-4521-abe5-6a22b05d885e
private void initCells() { for(int i = 0; i < width; i++) { for(int j = 0; j < height; j++) { grid[i][j] = new Cell(i, j, this); } } }
71f4f5d4-0513-46a0-ba6f-8a5a7d38271d
private void initBorders() { for(int i = 0; i < height; i++) { grid[0][i] = new Fence(0, i, this); grid[width-1][i] = new Fence(width-1, i, this); } //Offset by 1 because corner for(int i = 1; i < width; i++) { grid[i][0] = new Fence(i, 0, this); grid[i][height-1] = new Fence(i, height-1, this); }...
6239a08d-cb8a-452e-8676-be1a4e7b7c15
private void initInsideFences() { for(int i = 0; i < 20; i++) { Fence newFence = initRandFence(); if(!(grid[newFence.getX()][newFence.getY()] instanceof Fence)) { grid[newFence.getX()][newFence.getY()] = newFence; } else i--; } }
5cbf817f-efd8-4b3d-ac39-60b7bbb3edb7
private Fence initRandFence() { int x = (int) (Math.random()*w+1); int y = (int) (Math.random()*h+1); return new Fence(x, y, this); }
d0fc548e-db31-4230-b48d-84a2f6626eda
private void initEnemies() { for(int i = 0; i < 12; i++) { Mho newEnemy = initRandMho(); if(!(grid[newEnemy.getX()][newEnemy.getY()] instanceof Fence) && !(grid[newEnemy.getX()][newEnemy.getY()].contains(Mho.class))) { grid[newEnemy.getX()][newEnemy.getY()].occupy(newEnemy); } else i--; } }
4244676e-f06b-4380-ba8a-cb269aa2de36
private Mho initRandMho() { int x = (int) (Math.random()*w+1); int y = (int) (Math.random()*h+1); return new Mho(x, y, grid[x][y]); }
de71416a-7a52-4f31-bda7-7a3d749677f1
private void initPlayer(int playerNum) { int x = (int) (Math.random()*(width-1)); int y = (int) (Math.random()*(height-1)); Player player = new Player(x, y, grid[x][y]); if (!(grid[player.getX()][player.getY()] instanceof Fence) && !(grid[player.getX()][player.getY()].contains(Mho.class))) grid[player.getX(...
58f72051-ea79-4867-ad82-dec7b111441f
public void drawCells(Graphics g) { for (int row = 0; row < width; row++) { for (int col = 0; col < height; col++) { grid[row][col].draw(25, 35, cellWidth, cellHeight, g); } } }
8dbf9f3d-606b-47b0-a930-f52af99c924c
public void setScale() { w = getWidth(); h = getHeight(); cellWidth = (w-100)/width; cellHeight = (h-100)/height; }
075caccf-5e5a-4038-9b06-22eb6437ddbe
public void paintComponent(Graphics g) { setScale(); //makes the grid scale according to panel size if(!background) { g.drawImage(Player.getImage(), 25, 35, (cellWidth+1)*this.width+1, (cellHeight+1)*this.height+1, null); background = trace; } g.setColor(Color.CYAN); drawCells(g); if(gui.getLose()) {...
8c2d46c6-2e4b-449f-88a3-9ce4a56db11f
public Player findPlayer() { for (Cell[] c : grid) { for (Cell cell : c) { if (cell.contains(Player.class)) { try { return (Player)cell.getOccupant(); } catch (Exception e) { System.err.println("Player not found."); } } } } return null; }
19f1ef5c-3553-4d92-9b7c-fa4b7943c4fe
public Player findPlayer2() { if(!p2) return null; else { for(Cell[] c : grid) { for(Cell cell : c) { if (cell.contains(Player.class)) { try { if((Player)cell.getOccupant() == findPlayer()) continue; else return (Player) cell.getOccupant(); } catch (Exception e) { System...
d215a7fc-0837-4f1c-b0a5-fa66fc0c1c70
public void nextTurn() { boolean allDead = true; for (Cell[] c : grid) { for (Cell cell : c) { if (cell.contains(Mho.class)) { Mho mho = (Mho) cell.getOccupant(); if(!p2) mho.ai(this.findPlayer()); //In 2 player, moves towards closer target else { double p1Distance = mho.distanceTo(...
184eac60-f4d8-4bf3-967f-1144cde8891e
public Gui(boolean twoPlayer, int x, int y, int width, int height) { super("Hivolts"); p2 = twoPlayer; if(width == 0 || height == 0) { WIDTH = x*50 + 100; HEIGHT = y*50 + 100; } else { WIDTH = width; HEIGHT = height; } rows = x; cols = y; setPreferredSize(new Dimension(WIDTH, HEIGHT)); g...
aa7c7d4b-a067-4ca0-939d-886a0ec27948
public GridPanel getGrid() { return grid; }
d7a73cfb-2319-4314-97d8-72ea390f1e7e
public boolean getLose() { return lose; }
3eab1fab-0d28-4b16-9c2e-868b9e020a81
public boolean getWin() { return win; }
0162421c-1b83-445e-95eb-22d6d369e18b
@Override public void keyTyped(KeyEvent e) { }
31c87b99-f175-4981-8110-f9b195dfa01f
@Override public void keyPressed(KeyEvent e) { int c = e.getKeyCode(); if (!lose && !win) { //Uses switch case falling to do the same thing for different inputs switch (c) { case KeyEvent.VK_Q: case KeyEvent.VK_7: case KeyEvent.VK_NUMPAD7: grid.findPlayer().move(-1, -1); grid.nextTurn(); ...
45a83b39-7b03-4002-8b8a-52f7642b3f84
@Override public void keyReleased(KeyEvent e) { }
92cae956-b440-4de8-8357-4ba05689fd7a
public void gameOver() { this.lose = true; grid.repaint(); drawButton(); }
8d1ab70c-4f58-4199-a5ff-787adb3eb26f
public void win() { this.win = true; grid.repaint(); drawButton(); }
06e5a206-967e-428f-b72a-7da32ba0ae27
private void drawButton() { restart = new RestartButton(); restart.setBounds(0, 0, 100, 36); add(restart); restart.setVisible(true); restart.repaint(); }
7893dcdf-4db0-40cf-91df-5bbc05ea30d7
public void restart() { this.dispose(); new Gui(p2, rows, cols, this.getWidth(), this.getHeight()); }
2f73e6d2-fe6c-4f67-9d92-31e6778cfd17
RestartButton() { super("Restart"); addActionListener(this); }
1791fd3d-cffb-4ac9-9c38-911e6f056fed
public void actionPerformed(ActionEvent arg0) { restart(); }
82d114b5-e91f-43c8-916c-355f60419020
public Cell(int x, int y, GridPanel grid) { this.x = x; this.y = y; this.grid = grid; }
27710d93-1887-46c2-aee3-38a38e7c9df4
public GridPanel getGridPanel() { return grid; }
d163492f-87b4-44a4-b8d8-d738932e16de
public Mob getOccupant() { return this.occupant; }
950d8a02-fdc9-4345-be92-8423a37a99d1
public int getX() { return this.x; }
266b5c07-fb96-4dbf-b5b5-494d2cd09f0e
public int getY() { return this.y; }
f2b9ac46-dfc1-424f-ad5b-7c606870f7e9
public void occupy(Mob<? extends Mob> tenant) { occupant = tenant; }
7c25ed65-e7e6-4110-bfe4-8df55b3442f5
public <T> boolean contains(Class<T> c) { if (c.isInstance(this.occupant)) return true; return false; }
e791bb03-7fda-4018-9b7c-680d0c4be9bf
public void draw(int x_offset, int y_offset, int width, int height, Graphics g) { //int xleft = x_offset + 1 + (x * (width + 1)); //int ytop = y_offset + 1 + (y * (height + 1)); //g.drawImage(lab, xleft, ytop, width, height, null); if(contains(Mho.class)) { ((Mho)occupant).draw(x_offset, y_offset, width, hei...
f990a2d3-4a2f-401c-9fa8-8d379dfa02be
public Fence(int x, int y, GridPanel grid) { super(x, y, grid); }
d57bd537-03bb-4318-b40c-ee7461b27a01
public void draw(int x_offset, int y_offset, int width, int height,Graphics g) { int xleft = x_offset + (x * (width + 1)) + 1; int ytop = y_offset + (y * (height + 1)) + 1; g.drawImage(img, xleft, ytop, width, height, null); }
f310a041-add5-4c7c-ac75-b4420a02740b
protected Mob(int x, int y, Cell landlord) { this.x = x; this.y = y; this.landlord = landlord; }
1ba4ea2b-94f4-4789-9611-d24c3727a8b0
public int getX() { return this.x; }
df1069da-ca8d-42a4-b24e-0b6859b17b7e
public int getY() { return this.y; }
49133c57-f155-4f87-aa3a-9ca2c59e5eb1
public boolean move(int dx, int dy) { Cell destination = this.landlord.getGridPanel().getGrid()[this.x + dx][this.y + dy]; if (destination instanceof Fence) { this.destroy(dx, dy); return true; } this.x = landlord.getX() + dx; this.y = landlord.getY() + dy; destination.occupy((Mob<? extends Mob>) ...
8dfd9b52-cfbb-42af-aae3-9268df375445
public double distanceTo(int x1, int y1) { int dx = Math.abs(this.x - x1); int dy = Math.abs(this.y - y1); return Math.sqrt(dx ^ 2 + dy ^ 2); }
8f62bedd-0d0b-4dd6-a9e2-a5d5a5a07bce
public void destroy(int dx, int dy) { this.landlord.getGridPanel().getGrid()[this.x][this.y].occupy(null); }
d34901de-bf50-4246-bd30-ae80bf6081f0
public Player(int x, int y, Cell landlord) { super(x, y, landlord); try { img = ImageIO.read(new File("res/img/RaphiLangu.png")); } catch (IOException e) { } }
28a021fb-153d-45aa-9af2-713f8ebd6572
public static BufferedImage getImage() { return img; }
974f4ea4-c008-4dbc-894a-e0968ad70f4d
@Override public boolean move(int dx, int dy) { if ((this.x == 0 && dx < 0) || (this.x == this.landlord.getGridPanel().getGrid().length - 1 && dx > 0)) { dx = 0; } if ((this.y == 0 && dy < 0) || (this.y == this.landlord.getGridPanel().getGrid()[0].length - 1 && dy > 0)) { dy = 0; } Cell destina...
cfde9fcf-5deb-4d09-9a73-02a798dedb9d
public void destroy(int dx, int dy) { this.x = landlord.getX() + dx; this.y = landlord.getY() + dy; this.landlord.getGridPanel().getGui().gameOver(); super.destroy(dx, dy); }
a4bcd5db-a6ae-453d-9a56-a374817ae230
public void jump() { Cell[][] grid = this.landlord.getGridPanel().getGrid(); // -2 because of fences on the sides int width = this.landlord.getGridPanel().getW(); int height = this.landlord.getGridPanel().getH(); // +1 because of the fence on the side int x = (int) (Math.random() * width); int y = (int) ...
a8544dd3-e968-44f9-9bce-e8feb5017fb8
public void draw(int x_offset, int y_offset, int width, int height, Graphics g) { int xleft = x_offset + (x * (width + 1)) + 1; int ytop = y_offset + (y * (height + 1)) + 1; g.drawImage(img, xleft, ytop, width, height, null); }
e8ae1475-75dd-4cfd-9193-b2c2b06484d8
public Mho(int x, int y, Cell landlord) { super(x, y, landlord); double rand = Math.random(); //Randomly selects which image to represent the Mho if(rand<(1/numImg)) { try { img = ImageIO.read(new File("res/img/Aleca Tarng.png")); } catch (IOException e) { } } else if(rand<(2/numImg)) { try ...
3d337c90-c870-452f-a5d1-3b3530862855
@Override public boolean move(int dx, int dy){ if((this.x == 0 && dx < 0) || (this.x == this.landlord.getGridPanel().getGrid().length - 1 && dx > 0)) { dx = 0; } if((this.y == 0 && dy < 0) || (this.y == this.landlord.getGridPanel().getGrid()[0].length - 1 && dy > 0)) { dy = 0; } Cell destination = this...
e838ab0a-b1dc-48d1-87b0-89a185d4e821
public void destroy(int dx, int dy) { super.destroy(dx, dy); }
4768c2e8-3f1f-44be-bc1f-c06edb2adbb1
public void ai(Player player) { if (!moved) { try { //Finds external data Cell[][] grid = this.landlord.getGridPanel().getGrid(); int playerX = player.x; int playerY = player.y; //Mho will have moved moved = true; //Find the relative positions to travel int dx = (this.x < playerX...
d51c31d0-adcd-4288-a716-2c579ba28111
public void draw(int x_offset, int y_offset, int width, int height, Graphics g) { int xleft = x_offset + (x * (width + 1)) + 1; int ytop = y_offset + (y * (height + 1)) + 1; g.drawImage(img, xleft, ytop, width, height, null); }
bad3e543-89c3-4e35-95ea-26fd87ea458f
public int getId() { return id; }
f09bfc22-f8e5-424a-ba76-a8fdeb3d1325
public void setId(int id) { this.id = id; }
bee49906-0c7f-4949-857c-432291822f28
public String getName() { return name; }
c958da23-b25f-4fdf-ab2f-c021452cc7b0
public void setName(String name) { this.name = name; }
6859392d-b9a2-4af4-a727-217799dc0cf2
public Set<Group> getGroups() { return groups; }
6fd01909-8085-43af-bd1a-6dcb50d6a4c6
public void setGroups(Set<Group> groups) { this.groups = groups; }
607bd3dd-7448-45a3-92e0-7432ed4ad619
public Set<Group> getGroups() { return groups; }
55b2654c-2f1e-40c8-96f8-8eb628d47ad2
public void setGroups(Set<Group> groups) { this.groups = groups; }
5267539e-9348-4ace-89d8-b05e049c3e1b
public int getId() { return id; }
14b4feaa-1825-4af5-b8bf-dd02b8c8210d
public void setId(int id) { this.id = id; }
4ac3616e-83db-4a88-b71b-1eb420bc3d83
public String getLogin() { return login; }
d8868aba-5b13-4308-9187-1131aed19fcf
public void setLogin(String login) { this.login = login; }
8b96f7c6-d6ab-4cac-9d0d-2e52891f24d4
public String getEmail() { return email; }
3235f019-c75a-4fdf-a26b-fffa9bd07a92
public void setEmail(String email) { this.email = email; }
d1ce3b30-73fe-4b56-b6e5-5f781a110cf2
public String getPassword() { return password; }
d3f4a750-5508-4f2b-a9d1-0e4548d6976c
public void setPassword(String password) { this.password = password; }
b6f4ed2b-ce7b-4349-b5e9-5335dff972a4
public String getFirstName() { return firstName; }
9604174c-dfbc-40d2-bbe2-69b2b82e7caf
public void setFirstName(String firstName) { this.firstName = firstName; }