-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gabrielxp
committed
Jul 4, 2017
1 parent
31d715a
commit 0a21184
Showing
4 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
package view; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.canvas.Canvas; | ||
import javafx.scene.canvas.GraphicsContext; | ||
import javafx.scene.control.ScrollPane; | ||
import javafx.scene.control.TextField; | ||
import javafx.scene.layout.AnchorPane; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.text.Font; | ||
import javafx.scene.text.FontWeight; | ||
import javafx.stage.FileChooser; | ||
|
||
import java.io.*; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class Controller { | ||
|
||
@FXML | ||
private TextField inputCaminho; | ||
|
||
private FileChooser fileChooser; | ||
|
||
private StringBuffer stringBuffer; | ||
|
||
private StringBuffer stringBufferXPluPlus; | ||
|
||
@FXML | ||
private ScrollPane scrollPaneOutput; | ||
|
||
@FXML | ||
private AnchorPane panelnternoScroll; | ||
|
||
private List<String> linhas = new ArrayList<>(); | ||
|
||
public void buscar(){ | ||
stringBuffer = new StringBuffer(); | ||
|
||
fileChooser = new FileChooser(); | ||
fileChooser.setTitle("Selecione o Arquivo de Mapeamento"); | ||
File selectedFile = fileChooser.showOpenDialog(null); | ||
|
||
File xPlusPlusSelected = null; | ||
if (selectedFile != null) { | ||
try { | ||
BufferedReader bufferedReader = new BufferedReader(new FileReader(selectedFile)); | ||
|
||
String s = bufferedReader.readLine(); | ||
|
||
while (s != null){ | ||
stringBuffer.append(s); | ||
s = bufferedReader.readLine(); | ||
} | ||
|
||
List<Mapeamento> maps = processaMapeamento(stringBuffer.toString()); | ||
|
||
fileChooser = new FileChooser(); | ||
fileChooser.setTitle("Selecione o X++"); | ||
xPlusPlusSelected = fileChooser.showOpenDialog(null); | ||
|
||
BufferedReader bufferedReader2 = new BufferedReader(new FileReader(xPlusPlusSelected)); | ||
|
||
String s2 = bufferedReader2.readLine(); | ||
stringBufferXPluPlus = new StringBuffer(); | ||
linhas.add(s2); | ||
while (s2 != null){ | ||
stringBufferXPluPlus.append(s2); | ||
s2 = bufferedReader2.readLine(); | ||
linhas.add(s2); | ||
} | ||
|
||
processaContextoGrafico(maps); | ||
|
||
|
||
|
||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
}catch (IOException e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} | ||
|
||
public List<Mapeamento> processaMapeamento(String a){ | ||
|
||
String vectorMap[] = a.replace("{", "1").split("\\|"); | ||
List<Mapeamento> mapeamentos = new ArrayList<>(); | ||
|
||
for (int i = 0; i < vectorMap.length; i++){ | ||
|
||
String vetorPontoEVirgula[] = vectorMap[i].split(";"); | ||
Map<String, Integer> objetos = new HashMap(); | ||
|
||
for (int c = 0; c < vetorPontoEVirgula.length; c++) { | ||
|
||
String value = vetorPontoEVirgula[c].split("=")[0].trim(); | ||
if("beginColumn".equals(value) || "endColumn".equals(value) || "endLine".equals(value) || "beginLine".equals(value)) { | ||
objetos.put(value, Integer.parseInt(vetorPontoEVirgula[c].split("=")[1])); | ||
} | ||
} | ||
|
||
Mapeamento mapeamento = new Mapeamento(); | ||
mapeamento.setColunaInicio(objetos.get("beginColumn")); | ||
mapeamento.setColunaFim(objetos.get("endColumn")); | ||
mapeamento.setLinhaFim(objetos.get("endLine")); | ||
mapeamento.setLinhaInicio(objetos.get("beginLine")); | ||
mapeamentos.add(mapeamento); | ||
} | ||
return mapeamentos; | ||
} | ||
|
||
public void processaContextoGrafico( List<Mapeamento> maps){ | ||
|
||
int posicaox = 15; | ||
int posicaoy = 13; | ||
|
||
Canvas canvas = new Canvas( 637, 327); | ||
|
||
GraphicsContext gc2 = canvas.getGraphicsContext2D(); | ||
GraphicsContext gc = canvas.getGraphicsContext2D(); | ||
|
||
gc2.setFill( Color.BLUE ); | ||
gc.setFill( Color.RED ); | ||
gc.setStroke( Color.BLACK ); | ||
gc.setLineWidth(2); | ||
Font theFont = Font.font( "Times New Roman", FontWeight.BOLD, 12 ); | ||
gc.setFont( theFont ); | ||
gc2.setFont(theFont); | ||
|
||
panelnternoScroll.getChildren().add(canvas); | ||
|
||
|
||
for (int i = 0; i<linhas.size(); i++) { | ||
posicaoy = posicaoy + 13; | ||
|
||
gc.fillText( linhas.get(i), posicaox, posicaoy ); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package view; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
|
||
public class Main extends Application { | ||
|
||
|
||
|
||
@Override | ||
public void start(Stage primaryStage) throws Exception{ | ||
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); | ||
primaryStage.setTitle("Hello World"); | ||
primaryStage.setScene(new Scene(root, 850, 550)); | ||
primaryStage.show(); | ||
} | ||
|
||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package view; | ||
|
||
/** | ||
* Criado por Gabriel de Paula em 30/06/2017. | ||
*/ | ||
public class Mapeamento { | ||
|
||
private Integer colunaInicio; | ||
|
||
private Integer colunaFim; | ||
|
||
private Integer linhaInicio; | ||
|
||
private Integer linhaFim; | ||
|
||
public Integer getColunaInicio() { | ||
return colunaInicio; | ||
} | ||
|
||
public void setColunaInicio(Integer colunaInicio) { | ||
this.colunaInicio = colunaInicio; | ||
} | ||
|
||
public Integer getColunaFim() { | ||
return colunaFim; | ||
} | ||
|
||
public void setColunaFim(Integer colunaFim) { | ||
this.colunaFim = colunaFim; | ||
} | ||
|
||
public Integer getLinhaInicio() { | ||
return linhaInicio; | ||
} | ||
|
||
public void setLinhaInicio(Integer linhaInicio) { | ||
this.linhaInicio = linhaInicio; | ||
} | ||
|
||
public Integer getLinhaFim() { | ||
return linhaFim; | ||
} | ||
|
||
public void setLinhaFim(Integer linhaFim) { | ||
this.linhaFim = linhaFim; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Mapeamento{" + | ||
"colunaInicio=" + colunaInicio + | ||
", colunaFim=" + colunaFim + | ||
", linhaInicio=" + linhaInicio + | ||
", linhaFim=" + linhaFim + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.chart.CategoryAxis?> | ||
<?import javafx.scene.chart.NumberAxis?> | ||
<?import javafx.scene.chart.PieChart?> | ||
<?import javafx.scene.chart.StackedBarChart?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.ScrollPane?> | ||
<?import javafx.scene.layout.AnchorPane?> | ||
<?import javafx.scene.text.Font?> | ||
<?import javafx.scene.text.Text?> | ||
|
||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="545.0" prefWidth="874.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.Controller"> | ||
<children> | ||
<Button layoutX="395.0" layoutY="73.0" mnemonicParsing="false" onAction="#buscar" prefHeight="36.0" prefWidth="187.0" text="Arquivo de Mapeamento e X++" /> | ||
<StackedBarChart layoutX="598.0" layoutY="137.0" prefHeight="193.0" prefWidth="251.0"> | ||
<xAxis> | ||
<CategoryAxis side="BOTTOM" /> | ||
</xAxis> | ||
<yAxis> | ||
<NumberAxis side="LEFT" /> | ||
</yAxis> | ||
</StackedBarChart> | ||
<PieChart layoutX="637.0" layoutY="327.0" prefHeight="173.0" prefWidth="200.0" /> | ||
<Text layoutX="184.0" layoutY="40.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Analisador de Cobertura"> | ||
<font> | ||
<Font name="Engravers MT" size="23.0" /> | ||
</font> | ||
</Text> | ||
<AnchorPane layoutX="65.0" layoutY="177.0" minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0" /> | ||
<ScrollPane fx:id="scrollPaneOutput" layoutX="79.0" layoutY="136.0" prefHeight="339.0" prefWidth="503.0"> | ||
<content> | ||
<AnchorPane fx:id="panelnternoScroll" minHeight="0.0" minWidth="0.0" prefHeight="406.0" prefWidth="483.0" /> | ||
</content> | ||
</ScrollPane> | ||
</children> | ||
</AnchorPane> |