Skip to content

Commit

Permalink
Got rid of all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBelcher committed Nov 20, 2016
1 parent 7644d65 commit 3af6532
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

import be.quodlibet.boxable.BaseTable;
import be.quodlibet.boxable.datatable.DataTable;
import main.java.com.evanbelcher.DrillSweet2.data.DS2ConcurrentHashMap;
Expand Down Expand Up @@ -77,8 +78,7 @@ private void getDotSheetData() {
* @since 1.0
* @deprecated
*/
@Override
public void paintComponent(Graphics g) {
@Override public void paintComponent(Graphics g) {
g.clearRect(0, 0, WIDTH, HEIGHT);
g.setColor(Color.WHITE);
g.fillRect(0, 0, WIDTH, HEIGHT);
Expand Down Expand Up @@ -117,7 +117,7 @@ public void paintComponent(Graphics g) {
* @since 1.0
* @deprecated
*/
public void printAll() {
@SuppressWarnings("unused") public void printAll() {
int height = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB).createGraphics().getFontMetrics().getHeight();
String folder = DS2MenuBar.cleanseFileName(Main.getState().getCurrentFileName().substring(0, Main.getState().getCurrentFileName().length() - 5), 0) + "/Dot Sheets/";
File f = new File(Main.getFilePath() + folder);
Expand All @@ -132,6 +132,7 @@ public void printAll() {

BufferedImage bi = new BufferedImage(getSize().width, getSize().height, BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.createGraphics();
//noinspection deprecation
paintComponent(g);
g.dispose();
try {
Expand Down Expand Up @@ -172,8 +173,7 @@ private void printAllToPdf() throws IOException {
PDPage page = new PDPage();
doc.addPage(page);

@SuppressWarnings({ "rawtypes", "unchecked" })
List<List> data = new ArrayList();
@SuppressWarnings({ "rawtypes", "unchecked" }) List<List> data = new ArrayList();

PDFont font = PDType1Font.HELVETICA_BOLD;
PDPageContentStream contentStream = new PDPageContentStream(doc, page);
Expand Down Expand Up @@ -208,11 +208,10 @@ private void printAllToPdf() throws IOException {
float margin = 10;
float tableWidth = page.getMediaBox().getWidth() - (2 * margin);
float yStartNewPage = page.getMediaBox().getHeight() - (3 * margin);
boolean drawContent = true;
boolean drawLines = true;
//noinspection UnnecessaryLocalVariable
float yStart = yStartNewPage;
float bottomMargin = 70;
BaseTable baseTable = new BaseTable(yStart, yStartNewPage, bottomMargin, tableWidth, margin, doc, page, drawLines, drawContent);
BaseTable baseTable = new BaseTable(yStart, yStartNewPage, bottomMargin, tableWidth, margin, doc, page, true, true);
DataTable dataTable = new DataTable(baseTable, page);
dataTable.addListToTable(data, DataTable.HASHEADER);
baseTable.draw();
Expand All @@ -226,9 +225,9 @@ private void printAllToPdf() throws IOException {
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
finally {
doc.close();
} finally {
if (doc != null)
doc.close();
}
printing = false;
}
Expand All @@ -247,6 +246,7 @@ public void printDotSheets() throws InterruptedException {

/**
* Returns printing
*
* @since 1.0
*/
public static boolean isPrinting() {
Expand Down
16 changes: 9 additions & 7 deletions DrillSweet 2/src/main/java/com/evanbelcher/DrillSweet2/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.lang.reflect.Type;
import java.util.concurrent.ConcurrentHashMap;
import javax.swing.filechooser.FileSystemView;

import main.java.com.evanbelcher.DrillSweet2.data.*;
import main.java.com.evanbelcher.DrillSweet2.display.GraphicsRunner;
import com.google.gson.*;
Expand All @@ -17,7 +18,7 @@
* @version 1.0
* @since 1.0
*/
public class Main {
@SuppressWarnings("SynchronizeOnNonFinalField") public class Main {

private static ConcurrentHashMap<Integer, Page> pages;
private static State state;
Expand Down Expand Up @@ -65,6 +66,7 @@ private static void start() {
graphicsRunner.setWindowTitle("DrillSweet 2 - " + pagesFileName);
new Thread(graphicsRunner, "GraphicsThread").start();
new Thread(() -> {
//noinspection InfiniteLoopStatement
while (true) {
try {
Thread.sleep(120000);
Expand Down Expand Up @@ -118,7 +120,7 @@ public static void load() {
* Loads the state from the STATE file
*
* @throws FileNotFoundException if the STATE file cannot be found; this is handled by the
* load() method
* load() method
* @since 1.0
*/
private static void loadState() throws FileNotFoundException {
Expand All @@ -131,7 +133,7 @@ private static void loadState() throws FileNotFoundException {
* Loads the pages from the json file
*
* @throws FileNotFoundException if the json file cannot be found; this is handled by the load()
* method
* method
* @since 1.0
*/
private static void loadPages() throws FileNotFoundException {
Expand Down Expand Up @@ -233,10 +235,10 @@ public static void addPage() {
* Add the given page at the given index
*
* @param index the index for the page
* @param page the page to be added
* @param page the page to be added
* @since 1.0
*/
public static void addPage(int index, Page page) {
@SuppressWarnings("unused") public static void addPage(int index, Page page) {
pages.put(index, page);
}

Expand All @@ -246,7 +248,7 @@ public static void addPage(int index, Page page) {
* @since 1.0
*/
public static ConcurrentHashMap<Integer, Page> getPages() {
return new ConcurrentHashMap<Integer, Page>(pages);
return new ConcurrentHashMap<>(pages);
}

/**
Expand Down Expand Up @@ -332,7 +334,7 @@ public static void setPagesFileName(String pagesFileName) {
* @return requested file
* @since 1.0
*/
public static File getFile(String file) {
@SuppressWarnings("ConstantConditions") public static File getFile(String file) {
ClassLoader classLoader = Main.class.getClassLoader();
return new File(classLoader.getResource(file).getFile().replaceAll("%20", " "));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @version 1.0
* @since 1.0
*/
public class Page {
@SuppressWarnings("unused") public class Page {

private int number;
private String song;
Expand Down Expand Up @@ -42,10 +42,10 @@ public Page(int number) {
* Constructs the page object with the given number, song, starting measure, and dots. Uses the
* starting measure as both the starting and ending measures. All other fields are default.
*
* @param number the page number
* @param song the song title
* @param number the page number
* @param song the song title
* @param startingMeasure he starting measure number
* @param dots the map of dots
* @param dots the map of dots
* @since 1.0
*/
public Page(int number, String song, int startingMeasure, DS2ConcurrentHashMap<Point, String> dots) {
Expand All @@ -62,14 +62,14 @@ public Page(int number, String song, int startingMeasure, DS2ConcurrentHashMap<P
/**
* Constructs the page object with no default values.
*
* @param number the page number
* @param song the song title
* @param number the page number
* @param song the song title
* @param startingMeasure the starting measure
* @param endingMeasure the ending measure
* @param counts the counts
* @param notes the notes
* @param textPoint the top-left corner for the page text to be drawn at
* @param dots the map of dots
* @param endingMeasure the ending measure
* @param counts the counts
* @param notes the notes
* @param textPoint the top-left corner for the page text to be drawn at
* @param dots the map of dots
* @since 1.0
*/
public Page(int number, String song, int startingMeasure, int endingMeasure, int counts, String notes, Point textPoint, DS2ConcurrentHashMap<Point, String> dots) {
Expand Down Expand Up @@ -251,8 +251,7 @@ public String toDisplayString() {
* @return String representation of this object
* @since 1.0
*/
@Override
public String toString() {
@Override public String toString() {
return "Page [number=" + number + ", song=" + song + ", startingMeasure=" + startingMeasure + ", endingMeasure=" + endingMeasure + ", counts=" + counts + ", notes=" + notes + ", dots=" + dots + "]";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.JDesktopPane;

import org.apache.pdfbox.pdmodel.*;
import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
Expand All @@ -19,7 +20,8 @@
* @author Evan Belcher
* @version 1.0
*/
class DS2DesktopPane extends JDesktopPane implements MouseListener {
@SuppressWarnings("ConstantConditions") class DS2DesktopPane extends JDesktopPane
implements MouseListener {

private static final long serialVersionUID = -6004681236445735439L;

Expand Down Expand Up @@ -146,8 +148,7 @@ private PageDataFrame createPageDataFrame() {
*
* @since 1.0
*/
@Override
public void paintComponent(Graphics g) {
@Override public void paintComponent(Graphics g) {
g.clearRect(0, 0, GraphicsRunner.SCREEN_SIZE.width, GraphicsRunner.SCREEN_SIZE.height);
g.setColor(Color.WHITE);
g.fillRect(0, 0, GraphicsRunner.SCREEN_SIZE.width, GraphicsRunner.SCREEN_SIZE.height);
Expand All @@ -159,8 +160,7 @@ public void paintComponent(Graphics g) {
getFieldSize();
} catch (IOException e) {
e.printStackTrace();
}
finally {
} finally {
first = false;
}
}
Expand Down Expand Up @@ -224,7 +224,7 @@ public void paintComponent(Graphics g) {
* @since 1.0
* @deprecated
*/
protected void printCurrentPage(boolean makeFolder) {
@SuppressWarnings("unused") protected void printCurrentPage(boolean makeFolder) {
activePoint = null;
ddf.updateAll(activePoint);
String folder = "";
Expand Down Expand Up @@ -291,8 +291,7 @@ protected void printCurrentPageToPdf() throws IOException {

contentStream.close();
doc.save(f);
}
finally {
} finally {
if (doc != null)
doc.close();
}
Expand Down Expand Up @@ -358,8 +357,7 @@ protected void printAllPagesToPdf() throws IOException {
doc.save(f);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
finally {
} finally {
if (doc != null)
doc.close();
pdf.updateAfterPrintAll();
Expand All @@ -368,17 +366,15 @@ protected void printAllPagesToPdf() throws IOException {

//Mouselistener

@Override
public void mouseClicked(MouseEvent arg0) {
@Override public void mouseClicked(MouseEvent arg0) {
}

/**
* On mouse click (down). Adds a new point if there is none or selects the point.
*
* @since 1.0
*/
@Override
public void mousePressed(MouseEvent arg0) {
@Override public void mousePressed(MouseEvent arg0) {
//Forgive a one-pixel click out of bounds error
Point clickPoint = new Point(arg0.getPoint());
if (clickPoint.x == field.width + field.x + 1)
Expand Down Expand Up @@ -431,8 +427,7 @@ public void mousePressed(MouseEvent arg0) {
*
* @since 1.0
*/
@Override
public void mouseReleased(MouseEvent arg0) {
@Override public void mouseReleased(MouseEvent arg0) {

switch (arg0.getButton()) {
case 1:
Expand Down Expand Up @@ -476,12 +471,10 @@ public void mouseReleased(MouseEvent arg0) {
dragging = false;
}

@Override
public void mouseEntered(MouseEvent arg0) {
@Override public void mouseEntered(MouseEvent arg0) {
}

@Override
public void mouseExited(MouseEvent arg0) {
@Override public void mouseExited(MouseEvent arg0) {
}

/**
Expand Down
Loading

0 comments on commit 3af6532

Please sign in to comment.