id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
8fd341ea-3a35-4044-ab4f-b1fcf420e705 | public void setPersonId(long idperson) {
this.idperson = idperson;
} |
b366daba-22f8-4423-af36-bd8f4fffdcd1 | public long getCourseId() {
return idcourse;
} |
4b016eac-ab33-4e55-94f8-208a323affea | public void setCourseId(long idcourse) {
this.idcourse = idcourse;
} |
4a9eee15-d9c2-416e-9c27-fa9aa9a38df7 | public static void main(String[] args) {
// TODO code application logic here
int bosonSources = 1;
int bosonDrains = 1;
int fermionSources = 1;
int fermionDrains = 1;
int interactions = 2;
final List<QEDNode[]> diagrams = QEDDiagram.generateDiagrams(bosonSources, fermionSources, bosonDrains, fermionDrains, interactions);
//System.out.println("-----------------------");
System.out.println("diagrams: " + diagrams.size());
for(QEDNode[] d: diagrams){
QEDDiagram.show(d);
}
// SwingUtilities.invokeLater(new Runnable() {
//
// @Override
// public void run() {
//
// QEDDiagramCanvas canvas = new QEDDiagramCanvas();
// canvas.addDiagram(diagrams.get(0));
//
// QEDDiagramFrame frame = new QEDDiagramFrame(canvas);
//
// }
// });
} |
403691ab-1732-4294-8e56-0017893eccef | Type copy(); |
c7d81b9e-7809-41e1-b1c4-7b93ef4d899d | public QEDDiagramFrame(QEDDiagramCanvas canvas) {
setTitle("Diagrams");
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel panel = new JPanel(new BorderLayout());
panel.add(canvas, BorderLayout.CENTER);
getContentPane().add(panel);
setVisible(true);
} |
39485fa4-9fc9-451b-b071-4784afd4d468 | public void addDiagram(QEDNode[] diagram) {
diagrams.add(diagram);
} |
bb6d75d5-558e-4fb6-a3c8-f4730e895af2 | @Override
public void paint(Graphics g) {
//super.paint(grphcs);
Graphics2D g2 = (Graphics2D) g;
g2.translate(QEDDiagramFrame.WIDTH / 2, QEDDiagramFrame.HEIGHT / 2);
g2.scale(1, -1);
int n = 0;
for (QEDNode[] diagram : diagrams) {
draw(g2, n, diagram);
n++;
}
} |
a8193882-2e8d-4a37-8bc7-34cf538ca0ea | void draw(Graphics2D g, int n, QEDNode[] diagram) {
int N = diagram.length;
double angle = 2 * Math.PI / N;
for (int i = 0; i < N; i++) {
draw(g, diagram[i], i, angle);
}
} |
ff77f67f-8bf4-43c1-8aef-fd77600cc63b | void draw(Graphics2D g, QEDNode node, int index, double angle) {
int radius = 15;
double x = r * Math.cos(index * angle);
double y = r * Math.sin(index * angle);
Color color = Color.BLACK;
switch (node.getType()) {
case BOSON_DRAIN:
case BOSON_SOURCE:
color = color.ORANGE;
break;
case FERMION_SOURCE:
case FERMION_DRAIN:
color = color.BLUE;
break;
case INTERACTION:
color = Color.GREEN;
break;
}
drawCircle(g, x, y, radius, color);
} |
2011b3a1-0ae0-4d0d-9b15-ab125749ab61 | void drawCircle(Graphics2D g, double x, double y, double r, Color color) {
int rr = (int) (2 * r);
g.setColor(color);
g.fillOval((int) (x - r), (int) (y - r), rr, rr);
g.setColor(Color.BLACK);
g.drawOval((int) (x - r), (int) (y - r), rr, rr);
} |
829dce39-f070-4583-be47-3a2fbda3ba8d | @Override
public String toString() {
switch (this) {
case BOSON_SOURCE:
return "Bs";
case BOSON_DRAIN:
return "Bd";
case FERMION_SOURCE:
return "Fs";
case FERMION_DRAIN:
return "Fd";
case INTERACTION:
return "In";
default:
return "UNKNOWN";
}
} |
e1e6afef-c03d-4ebc-a7fe-b7686de3fd6b | public BosonNode(boolean source) {
super(1, 0);
this.type = source? QEDNodeType.BOSON_SOURCE : QEDNodeType.BOSON_DRAIN;
} |
b452b134-7ba9-4776-a664-2d812e458f5f | public InteractionNode() {
super(1, 2);
type = QEDNodeType.INTERACTION;
} |
7c8e7662-ff33-4884-a945-a441213a8fae | public FermionNode(boolean source) {
super(0,1);
this.type = source? QEDNodeType.FERMION_SOURCE : QEDNodeType.FERMION_DRAIN;
} |
83b8fe80-71e4-45aa-b09b-0825120d04a4 | public QEDDiagram(int bosonSources, int fermionSources, int bosonDrains, int fermionDrains, int interactions) {
this.bosonSources = new BosonNode[bosonSources];
this.bosonDrains = new BosonNode[bosonDrains];
this.fermionSources = new FermionNode[fermionSources];
this.fermionDrains = new FermionNode[fermionDrains];
this.interactions = new InteractionNode[interactions];
} |
45056097-9a00-4f58-8236-f8e28a91c78c | public static List<QEDNode[]> generateDiagrams(int bosonSources, int fermionSources, int bosonDrains, int fermionDrains, int interactions) {
int N = bosonSources + bosonDrains + fermionSources + fermionDrains + interactions;
Stack<QEDNode[]> nodesStack = new Stack<QEDNode[]>();
List<QEDNode[]> completed = new LinkedList<>();
// QEDList<QEDNode> handled = new QEDList<>(N);
// QEDList<QEDNode> unhandled = new QEDList<>(N);
QEDNode[] nodes = new QEDNode[N];
int k = 0;
for (int i = 0; i < bosonSources; i++) {
nodes[i + k] = new BosonNode(true);
}
k += bosonSources;
for (int i = 0; i < bosonDrains; i++) {
nodes[i + k] = new BosonNode(false);
}
k += bosonDrains;
for (int i = 0; i < fermionSources; i++) {
nodes[i + k] = new FermionNode(true);
}
k += fermionSources;
for (int i = 0; i < fermionDrains; i++) {
nodes[i + k] = new FermionNode(false);
}
k += fermionDrains;
for (int i = 0; i < interactions; i++) {
nodes[i + k] = new InteractionNode();
}
//System.out.println(unhandled);
//QEDNode current = unhandled.remove();
//System.out.println("current: " + current);
// System.out.println("nodes: ");
//
// for (QEDNode node : nodes) {
// System.out.println("node: " + node);
// }
nodesStack.push(nodes);
while (!nodesStack.isEmpty()) {
nodes = nodesStack.pop();
//show(nodes);
boolean hasFreeLinks = false;
for (int i = 0; i < N; i++) {
QEDNode node1 = nodes[i];
//System.out.println("node1 " + i + ") " + node1);
if (!node1.hasFreeLinks()) {
//System.out.println("no free links: " + node1);
continue;
}
hasFreeLinks = true;
for (int j = i + 1; j < N; j++) {
QEDNode node2 = nodes[j];
//System.out.println("node2: " + node2);
if (canBeConnected(node1, node2)) {
//System.out.println("can be connected: " + i + ", " + j);
QEDNode[] copy = copy(nodes);
connect(copy[i], i, copy[j], j);
nodesStack.push(copy);
}
}
//System.out.println("");
}
if (!hasFreeLinks) {
//System.out.println("COMPLETED: ");
//show(nodes);
completed.add(nodes);
}
}
//System.out.println("-----------------------");
// System.out.println("completed: " + completed.size());
// for(QEDNode[] d: completed){
// show(d);
// }
return completed;
} |
16ad717a-a82b-476e-b42d-a5e654b4eebd | static boolean canBeConnected(QEDNode node1, QEDNode node2) {
return node1.hasFreeBosonLinks() && node2.hasFreeBosonLinks()
|| node1.hasFreeFermionLinks() && node2.hasFreeFermionLinks();
} |
22b99730-00ba-4820-99c3-ac89bfed98c6 | static void connect(QEDNode node1, int index1, QEDNode node2, int index2) {
if (node1.hasFreeBosonLinks() && node2.hasFreeBosonLinks()) {
node1.addBoson(index2);
node2.addBoson(index1);
} else if (node1.hasFreeFermionLinks() && node2.hasFreeFermionLinks()) {
node1.addFermion(index2);
node2.addFermion(index1);
} else {
throw new RuntimeException();
}
} |
88744724-0de0-4526-a0b4-29c5e8982a8d | static QEDNode[] copy(QEDNode[] nodes) {
QEDNode[] copy = new QEDNode[nodes.length];
for (int i = 0; i < nodes.length; i++) {
copy[i] = nodes[i].copy();
}
return copy;
} |
74fe50a6-ef06-4153-8f23-7a274d1d742b | public static void show(QEDNode[] nodes) {
System.out.println("Diagram:");
for (int i = 0; i < nodes.length; i++) {
System.out.println(i + ") " + nodes[i]);
}
System.out.println();
} |
6b3225ea-51bc-48bc-b445-c50c2e4ee181 | private QEDNode() {
} |
a84da259-e080-4246-8363-9ecf0eb90621 | public QEDNode(int bosonsMaxNumber, int fermionsMaxNumber) {
//this.id = id;
this.bosonsMaxNumber = bosonsMaxNumber;
this.fermionsMaxNumber = fermionsMaxNumber;
bosons = new int[bosonsMaxNumber];
fermions = new int[fermionsMaxNumber];
} |
6ff5407b-b468-491f-b28d-910991c87d4e | public QEDNodeType getType() {
return type;
} |
49feb868-60c3-4dd9-ba48-a8d08f26d70c | public boolean hasFreeBosonLinks() {
return bosonsNumber < bosonsMaxNumber;
} |
2c3070fb-bafa-43a6-8e67-9ef45fbf43ae | public boolean hasFreeFermionLinks() {
return fermionsNumber < fermionsMaxNumber;
} |
b858c97c-3c80-4d73-bd59-35ca23e59646 | public boolean hasFreeLinks() {
return hasFreeBosonLinks() || hasFreeFermionLinks();
} |
f303a919-8461-4084-bf4c-bb6bee76ca90 | public void addBoson(int index) {
bosons[bosonsNumber++] = index;
} |
8da53558-4b74-4135-991a-5e142b57560a | public void addFermion(int index) {
fermions[fermionsNumber++] = index;
} |
0c121664-50d6-4fa5-90c0-d1a362489a73 | @Override
public QEDNode copy() {
QEDNode copy = new QEDNode();
copy.type = type;
// bosons
copy.bosonsMaxNumber = bosonsMaxNumber;
copy.bosonsNumber = bosonsNumber;
copy.bosons = Arrays.copyOf(bosons, bosonsMaxNumber);
// fermions
copy.fermionsMaxNumber = fermionsMaxNumber;
copy.fermionsNumber = fermionsNumber;
copy.fermions = Arrays.copyOf(fermions, fermionsMaxNumber);
return copy;
} |
5d5451b2-b6e1-49bf-b0bf-2a0907fb3025 | @Override
public String toString() {
//return type + " " + id;
String res = "bosons " + bosonsNumber + " of " + bosonsMaxNumber + ": [";
for (int i = 0; i < bosonsNumber; i++) {
res += bosons[i] + " ";
}
res += "] fermions " + fermionsNumber + " of " + fermionsMaxNumber + ": [";
for (int i = 0; i < fermionsNumber; i++) {
res += fermions[i] + " ";
}
res += "]";
return type + " " + res;
} |
13972fba-a012-4f7b-b6eb-a659ca180d0a | @Override
public Evaluation crossValidation(Classifier classifier, Instances data,
int numFolds, int numSeeds) throws Exception {
Evaluation eval = new Evaluation(data);
Random rand = new Random(numSeeds);
eval.crossValidateModel(classifier, data, numFolds, rand);
return eval;
} |
d388d056-fd64-4d81-ae8a-886a66a90aa9 | @Override
public double[][] getConfusionMatrix(Evaluation eval) {
double[][] cnMatrix = eval.confusionMatrix();
System.out.println("\nThe confusion Matrix");
for (int row_i = 0; row_i < cnMatrix.length; row_i++) {
for (int col_i = 0; col_i < cnMatrix.length; col_i++) {
System.out.print(cnMatrix[row_i][col_i]);
System.out.print("|");
}
System.out.println();
}
return cnMatrix;
} |
63d87fb1-6eb7-48cf-827c-b07e6308ece8 | @Override
public double getKappa(Evaluation eval) {
double kappaIndex = eval.kappa();
System.out.println("\nThe Kappa Index");
System.out.println(kappaIndex);
return kappaIndex;
} |
882d4d26-fac2-47a5-a5ea-e81e947661e5 | @Override
public void plotCurveROC(Evaluation eval) {
System.out.println("\nPlotting Curve ROC...");
// Generate the curve
ThresholdCurve tc = new ThresholdCurve();
Instances curve = tc.getCurve(eval.predictions());
// Plot the curve
ThresholdVisualizePanel tvp = new ThresholdVisualizePanel();
tvp.setROCString("(Area under ROC = "
+ Utils.doubleToString(ThresholdCurve.getROCArea(curve), 4)
+ ")");
tvp.setName(curve.relationName());
PlotData2D plotData = new PlotData2D(curve);
plotData.setPlotName(curve.relationName());
plotData.addInstanceNumberAttribute();
// Specifying the number of connected points, all
boolean[] cp = new boolean[curve.numInstances()];
for (int i = 0; i < cp.length; i++) {
cp[i] = true;
}
try {
plotData.setConnectPoints(cp);
tvp.addPlot(plotData);
} catch (Exception e) {
e.printStackTrace();
}
// Display curve
final JFrame jf = new JFrame("WEKA ROC: " + tvp.getName());
jf.setSize(500, 400);
jf.getContentPane().setLayout(new BorderLayout());
jf.getContentPane().add(tvp, BorderLayout.CENTER);
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
jf.setVisible(true);
System.out.println("...Finish!");
} |
0366f6a9-f0c5-4ecb-8119-d7517d7598a6 | @Override
public void printClassifierOutput(Instances data, Classifier cl,
Evaluation eval) throws Exception {
System.out.println("=== Instances summary (full training set) ===\n");
System.out.println(data.toSummaryString());
System.out.println("=== Classifier model (full training set) ===\n");
System.out.println(cl + "\n");
System.out.println("=== Stratified cross-validation ===");
System.out.println("=== Summary ===");
System.out.println(eval.toSummaryString());
System.out.println(eval.toClassDetailsString());
System.out.println(eval.toMatrixString());
} |
31bc298b-3b40-43b4-9911-3ca7b3623978 | @Override
public void printInstancesData(Instances data) {
System.out.println("=== Instances ===");
System.out.println(data.toString() + "\n");
} |
f4db2ac9-cead-4bb6-9adb-edcc9a342bda | public Evaluation crossValidation(Classifier classifier, Instances data,
int numFolds, int numSeeds) throws Exception; |
7105c669-97fb-4a37-a0d3-baa0cf6f919d | public double[][] getConfusionMatrix(Evaluation eval); |
d7c19904-fe37-4ba3-8ce9-ac173d4f81ff | public double getKappa(Evaluation eval); |
61af71a8-1aa3-48a7-826e-65edb0244cd9 | public void plotCurveROC(Evaluation eval); |
368ac6f7-8c15-41e0-8022-4910c5b41fa1 | public void printClassifierOutput(Instances data, Classifier cl,
Evaluation eval) throws Exception; |
d0fcc049-612d-4ad7-ab23-ddf2dae38d0e | public void printInstancesData(Instances data); |
6bf9ee74-4a8b-4bca-b481-35dcc6432d85 | public static void main(String[] args) throws Exception {
// variables
int numFolds = 10;
int numSeeds = 1;
// load training data
Instances data = DataSource
.read("oscars.training.arff");
data.setClassIndex(data.numAttributes() - 1);
// select a classifier
Classifier cl = new VotedPerceptron();
cl.buildClassifier(data);
// performs 10-fold Cross-Validation to baseline classifier
EvaluateClassifier ec = new EvaluateClassifier();
Evaluation eval = ec.crossValidation(cl, data, numFolds, numSeeds);
ec.printInstancesData(data);
ec.printClassifierOutput(data, cl, eval);
// getCurveROC
ec.plotCurveROC(eval);
// getConfusionMatrix
// ec.getConfusionMatrix(eval);
// getKappa
// ec.getKappa(eval);
} |
907418f3-62ba-4cbf-81fb-ee718ca9c099 | public static void predict(String name, Integer total_nominations,
String category_next, String awarded_next) throws Exception {
System.out.println("\n\n");
System.out.println("*****************");
System.out.println("* TRAINING DATA *");
System.out.println("*****************");
// load training data
Instances data = DataSource.read("oscars.training.arff");
data.setClassIndex(data.numAttributes() - 1);
// train classifier
Classifier cl = new VotedPerceptron();
cl.buildClassifier(data);
// output on stdout
System.out.println(data);
// create new set of data
Instances newData = new Instances(data, 1);
Instance inst = new DenseInstance(5);
inst.setDataset(newData);
Thread.sleep(1000);
System.out.println("\n\n");
System.out.println("*****************");
System.out.println("* TEST DATA *");
System.out.println("*****************");
System.out.println(newData);
// add attribute values
inst.setValue(0, name);
inst.setValue(1, total_nominations);
inst.setValue(2, category_next);
inst.setValue(3, awarded_next);
System.out.println(inst);
// predict class
double pred = cl.classifyInstance(inst);
Thread.sleep(1000);
System.out.println("\n\n");
System.out.println("*****************");
System.out.println("* RESULTS *");
System.out.println("*****************");
// get prediction
System.out.println(inst.stringValue(0) + " will repeat nomination? "
+ data.classAttribute().value((int) pred).toUpperCase());
} |
ea2e132e-78fe-478d-a537-b948ca3999cd | public static void main(String[] args) throws Exception {
/**
* ATRIBUTES: name, total_nominations, category_next, available_next
* CLASS: class_repeat_nomination
*/
String name, category_next, awarded_next;
Integer total_nominations;
// name = "Jeff-Bridges";
// total_nominations = 6;
// category_next = "bestActor";
// awarded_next = "no";
try {
BufferedReader bufferRead = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("*****************");
System.out.println("* WELCOME *");
System.out.println("*****************");
System.out
.println("Please, introduces the following parameters...");
System.out.println("Actor");
name = bufferRead.readLine();
System.out.println("Total nominations");
total_nominations = Integer.parseInt(bufferRead.readLine());
System.out.println("Category next");
category_next = bufferRead.readLine();
System.out.println("Awarded next");
awarded_next = bufferRead.readLine();
predict(name, total_nominations, category_next, awarded_next);
} catch (IOException e) {
e.getMessage();
}
} |
f18e2c19-55fd-4ab4-b554-3b7375b8bc92 | public static void main(String[] args) throws Exception {
// load data
Instances data = DataSource.read(args[0]);
data.setClassIndex(data.numAttributes() - 1);
// evaluate classifier
Classifier cl = new NaiveBayes();
Evaluation eval = new Evaluation(data);
eval.crossValidateModel(cl, data, 10, new Random(1));
// generate curve
ThresholdCurve tc = new ThresholdCurve();
int classIndex = 0;
Instances curve = tc.getCurve(eval.predictions(), classIndex);
// plot curve
ThresholdVisualizePanel tvp = new ThresholdVisualizePanel();
tvp.setROCString("(Area under ROC = "
+ Utils.doubleToString(ThresholdCurve.getROCArea(curve), 4)
+ ")");
tvp.setName(curve.relationName());
PlotData2D plotdata = new PlotData2D(curve);
plotdata.setPlotName(curve.relationName());
plotdata.addInstanceNumberAttribute();
// specify which points are connected
boolean[] cp = new boolean[curve.numInstances()];
for (int n = 1; n < cp.length; n++)
cp[n] = true;
plotdata.setConnectPoints(cp);
// add plot
tvp.addPlot(plotdata);
// display curve
final JFrame jf = new JFrame("WEKA ROC: " + tvp.getName());
jf.setSize(500, 400);
jf.getContentPane().setLayout(new BorderLayout());
jf.getContentPane().add(tvp, BorderLayout.CENTER);
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
jf.setVisible(true);
} |
ab9a752b-0ba7-4e8f-8621-75b9580d0c05 | public static void main(String[] args) throws Exception {
// load dataset
Instances data = DataSource.read("/Users/nadim/Workspace/weka-3-7-10/data/weather.nominal.arff");
// Constructor creating an empty set of instances. Copies references to
// the header information from the given set of instances.
Instances newData = null;
newData = new Instances(data, 1);
// Create empty instance with 5 attribute values
Instance inst = new DenseInstance(5);
// Set instance's dataset to be the dataset "race"
inst.setDataset(newData);
// Set instance's values for the attributes "length", "weight", and
// "position"
// @attribute outlook {sunny, overcast, rainy}
// @attribute temperature {hot, mild, cool}
// @attribute humidity {high, normal}
// @attribute windy {TRUE, FALSE}
// @attribute play {yes, no}
inst.setValue(0, "sunny");
inst.setValue(1, "hot");
inst.setValue(2, "high");
inst.setValue(3, "TRUE");
// Print the instance
System.out.println("The instance: " + inst);
// output on stdout
System.out.println(data);
System.out.println(newData);
} |
6250e4a7-fc25-42ad-a000-9d6e585282ce | @SuppressWarnings({ "deprecation", "unchecked", "rawtypes" })
public static void main(String[] args) throws Exception {
// Declare two numeric attributes
Attribute Attribute1 = new Attribute("firstNumeric");
Attribute Attribute2 = new Attribute("secondNumeric");
// Declare a nominal attribute along with its values
FastVector fvNominalVal = new FastVector(3);
fvNominalVal.addElement("blue");
fvNominalVal.addElement("gray");
fvNominalVal.addElement("black");
Attribute Attribute3 = new Attribute("aNominal", fvNominalVal);
// Declare the class attribute along with its values
FastVector fvClassVal = new FastVector(2);
fvClassVal.addElement("positive");
fvClassVal.addElement("negative");
Attribute ClassAttribute = new Attribute("theClass", fvClassVal);
// Declare the feature vector
FastVector fvWekaAttributes = new FastVector(4);
fvWekaAttributes.addElement(Attribute1);
fvWekaAttributes.addElement(Attribute2);
fvWekaAttributes.addElement(Attribute3);
fvWekaAttributes.addElement(ClassAttribute);
// Create an empty training set
Instances isTrainingSet = new Instances("Rel", fvWekaAttributes, 10);
// Set class index
isTrainingSet.setClassIndex(3);
// Create the instance
Instance iExample = new DenseInstance(4);
iExample.setValue((Attribute) fvWekaAttributes.elementAt(0), 1.0);
iExample.setValue((Attribute) fvWekaAttributes.elementAt(1), 0.5);
iExample.setValue((Attribute) fvWekaAttributes.elementAt(2), "gray");
iExample.setValue((Attribute) fvWekaAttributes.elementAt(3), "positive");
// add the instance
isTrainingSet.add(iExample);
Classifier cModel = (Classifier) new NaiveBayes();
cModel.buildClassifier(isTrainingSet);
// Test the model
Evaluation eTest = new Evaluation(isTrainingSet);
eTest.evaluateModel(cModel, isTrainingSet);
// Print the result ?????? la Weka explorer:
String strSummary = eTest.toSummaryString();
System.out.println(strSummary);
// Get the confusion matrix
double[][] cmMatrix = eTest.confusionMatrix();
for (int row_i = 0; row_i < cmMatrix.length; row_i++) {
for (int col_i = 0; col_i < cmMatrix.length; col_i++) {
System.out.print(cmMatrix[row_i][col_i]);
System.out.print("|");
}
System.out.println();
}
} |
f79a2cac-6d12-441b-bb9c-cb1f951a4e14 | @Test
public void testThatIndexPageWorks() {
Response response = GET("/");
assertIsOk(response);
assertContentType("text/html", response);
assertCharset(play.Play.defaultWebEncoding, response);
} |
94e2cee7-769c-4b14-b2ca-913e9efc4ca6 | @Test
public void aVeryImportantThingToTest() {
assertEquals(2, 1 + 1);
} |
52fabeb4-dac5-4dfb-b20d-b2982d40317f | public TransportFile() {
} |
f423dd34-0f59-4676-80e4-72e94625d2a5 | public static void index() {
render();
} |
64362f22-ed55-4574-a24a-888b617e3d1a | public static void uploadFile(File uploadFile) throws Exception{
Logger.info("filename=" + uploadFile.getName());
InputStream is = new FileInputStream(uploadFile);
InputStreamReader isr = new InputStreamReader(is, "Shift_JIS");
CSVReader csvr = new CSVReader(isr);
String [] columns;
columns = csvr.readNext();
// for(String column : columns) {
// Logger.info("column=" + column);
// }
if(columns != null) {
// columnNames = csvr.readNext();
// while ((nextLine = csvr.readNext()) != null) {
// // nextLine[] is an array of values from the line
// Logger.info(nextLine[0] + nextLine[1] + "etc...");
// }
ColumnPositionMappingStrategy cpms = new ColumnPositionMappingStrategy();
cpms.setType(TransportFile.class);
cpms.setColumnMapping(columns);
// String[] columns2 = new String[] {"transportFileId", "transaction_applicationAdmin_areaName", "transaction_applicationAdmin_address"};
// cpms.setColumnMapping(columns2);
CsvToBean<TransportFile> csvToBean = new CsvToBean<TransportFile>();
List<TransportFile> transportFiles = csvToBean.parse(cpms, csvr);
for(TransportFile transportFile : transportFiles) {
// Logger.info("test=" + transportFile.transportFileId + ",2=" + transportFile.transaction_applicationAdmin_areaName + ",3=" + transportFile.transaction_applicationAdmin_address);
Logger.info("transportFile.column1=" + transportFile.column1);
// application(transportFile);
}
}
selectFile();
} |
59271752-9818-498d-9b74-ae4280996b5d | public static void selectFile() {
render();
} |
aeb6bf4f-641b-4a2d-b552-48d3841e4b7e | public Edge(String id, Vertex source, Vertex destination, int weight) {
this.id = id;
this.source = source;
this.destination = destination;
this.weight = weight;
} |
d5735e07-1504-47cd-9d5c-dbf2d706eb99 | public String getId() {
return id;
} |
304ab1ea-9fd8-4c76-ae8c-c4be7e686f57 | public Vertex getDestination() {
return destination;
} |
71d2971f-6a0c-43a4-a5ba-ea25b005211f | public Vertex getSource() {
return source;
} |
e4d4885b-6b78-46a2-9518-aa3b56596c80 | public int getWeight() {
return weight;
} |
0ca95ff8-5087-4389-a552-6167921ff4be | @Override
public String toString() {
return source + " " + destination;
} |
545e2f3a-fdd6-4662-a9fb-c79ff251326d | public Vertex(String id, String name) {
this.id = id;
this.name = name;
} |
2a144c73-61e0-4cde-96f4-7187cc84d456 | public String getId() {
return id;
} |
2ac23e3b-f768-4961-8da1-da1af4010e7e | public String getName() {
return name;
} |
165bcd82-4bc3-4b57-8e14-f759bd877936 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
} |
a8cbbcb6-9b18-4d7d-a033-b95664344cf4 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Vertex other = (Vertex) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
} |
ba84426c-47ab-4b28-9e9a-8a358d4581c3 | @Override
public String toString() {
return name;
} |
a37966e3-bb2e-49ed-beaa-583a99c96606 | @Test
public void testExcute() {
nodes = new ArrayList<Vertex>();
edges = new ArrayList<Edge>();
for (int i = 0; i < 11; i++) {
Vertex location = new Vertex("Node_" + i, "Node_" + i);
nodes.add(location);
}
addLane("Edge_0", 0, 1, 85);
addLane("Edge_1", 0, 2, 217);
addLane("Edge_2", 0, 4, 173);
addLane("Edge_3", 2, 6, 186);
addLane("Edge_4", 2, 7, 103);
addLane("Edge_5", 3, 7, 183);
addLane("Edge_6", 5, 8, 250);
addLane("Edge_7", 8, 9, 84);
addLane("Edge_8", 7, 9, 167);
addLane("Edge_9", 4, 9, 502);
addLane("Edge_10", 9, 10, 40);
addLane("Edge_11", 1, 10, 600);
// Lets check from location Loc_1 to Loc_10
Graph graph = new Graph(nodes, edges);
DijkstraShortPath dijkstra = new DijkstraShortPath(graph);
dijkstra.execute(nodes.get(0));
LinkedList<Vertex> path = dijkstra.getPath(nodes.get(10));
assertNotNull(path);
assertTrue(path.size() > 0);
for (Vertex vertex : path) {
System.out.println(vertex);
}
} |
bb37db70-9e6f-4c13-84fd-85fe98bb7210 | private void addLane(String laneId, int sourceLocNo, int destLocNo,
int duration) {
Edge lane = new Edge(laneId,nodes.get(sourceLocNo), nodes.get(destLocNo), duration);
edges.add(lane);
} |
f97a71de-97dd-49b3-b342-2399db090ec0 | public Graph(List<Vertex> vertexes, List<Edge> edges) {
this.vertexes = vertexes;
this.edges = edges;
} |
3c722ae2-a0b7-473f-914a-8cb9da003430 | public List<Vertex> getVertexes() {
return vertexes;
} |
f24c123b-e2bb-4132-92af-cb5aa8f50286 | public List<Edge> getEdges() {
return edges;
} |
8fbcdd82-9ba7-4877-a476-f2d934d6b507 | public Wall(int posX, int posY) {
super(posX, posY);
Image brick0 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/meth.png"));
animo = new Animacion();
animo.sumaCuadro(brick0, 100);
} |
77fd209e-96db-497d-8d0b-a460c687fb01 | public static String getPAUSADO() {
return PAUSADO;
} |
efe17611-01aa-4236-bc33-5542e115fbe4 | public static String getDESAPARECE() {
return DESAPARECE;
} |
04f0a72b-932a-4cf2-9974-b8c469044960 | public static void main(String[] args) {
//Todo el codigo de aplicacion aqui
flap juego = new flap();
juego.setVisible(true);
} |
b68f81e6-66de-4280-bf7e-8a1488f2a239 | public Malo(int posX, int posY) {
super(posX, posY);
Image bomb0 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/Pelota0.gif"));
Image bomb1 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/Pelota1.gif"));
Image bomb2 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/Pelota2.gif"));
//Se crea la animación
animo = new Animacion();
animo.sumaCuadro(bomb0, 100);
animo.sumaCuadro(bomb1, 100);
animo.sumaCuadro(bomb2, 100);
} |
882aa59e-ed06-421c-a264-7f6dd7a38749 | public static int getConteo() {
return conteo;
} |
4db0a820-3111-498f-b696-f563a1eed952 | public static void setConteo(int cont) {
conteo = cont;
} |
54c35d8a-f961-49b1-8968-2a36e5ba29a7 | public int getSpeed() {
return speed;
} |
721585e1-2784-4eeb-80c1-9a9d9afa278d | public void setSpeed(int vel) {
speed = vel;
} |
afca3587-a360-411f-b435-be9a74c7275f | public Animacion() {
cuadros = new ArrayList();
duracionTotal = 0;
iniciar();
} |
23bcad6f-d4de-491b-ac72-b50272523367 | public synchronized void sumaCuadro(Image imagen, long duracion) {
duracionTotal += duracion;
cuadros.add(new cuadroDeAnimacion(imagen, duracionTotal));
} |
b38de7d2-fdd8-42e9-bb14-592d3f041ecc | public synchronized void iniciar() {
tiempoDeAnimacion = 0;
indiceCuadroActual = 0;
} |
bc961da9-c5ef-44b3-9632-ba83d76f7c25 | public synchronized void actualiza(long tiempoTranscurrido) {
if (cuadros.size() > 1) {
tiempoDeAnimacion += tiempoTranscurrido;
if (tiempoDeAnimacion >= duracionTotal) {
tiempoDeAnimacion = tiempoDeAnimacion % duracionTotal;
indiceCuadroActual = 0;
}
while (tiempoDeAnimacion > getCuadro(indiceCuadroActual).tiempoFinal) {
indiceCuadroActual++;
}
}
} |
75704db0-b9e3-44be-a7f4-4d5d80221432 | public synchronized Image getImagen() {
if (cuadros.size() == 0) {
return null;
} else {
return getCuadro(indiceCuadroActual).imagen;
}
} |
93fa36ad-f9ca-4bd5-956d-ea0da7fbb5cd | private cuadroDeAnimacion getCuadro(int i) {
return (cuadroDeAnimacion) cuadros.get(i);
} |
d83b560c-726d-42b8-a8cd-7e92504339a2 | public cuadroDeAnimacion() {
this.imagen = null;
this.tiempoFinal = 0;
} |
f799cf02-e203-43b7-ada5-70aec1415ba7 | public cuadroDeAnimacion(Image imagen, long tiempoFinal) {
this.imagen = imagen;
this.tiempoFinal = tiempoFinal;
} |
63a9f309-c322-4a14-88ca-cc757acf70f3 | public Image getImagen() {
return imagen;
} |
90441bf8-08e1-4cc8-9549-1b11aeb8240c | public long getTiempoFinal() {
return tiempoFinal;
} |
c0198d51-9260-4d48-bc75-6965418ac481 | public void setImagen(Image imagen) {
this.imagen = imagen;
} |
fa4656de-5b5d-4ebe-b1d9-c4e14b326710 | public void setTiempoFinal(long tiempoFinal) {
this.tiempoFinal = tiempoFinal;
} |
3c301d32-fd3a-4248-891d-b91d145059fa | public Birdy(int posX, int posY) {
super(posX, posY);
Image kirby0 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/1.png"));
Image kirby1 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/2.png"));
Image kirby2 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/3.png"));
Image kirby3 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/4.png"));
Image kirby4 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/5.png"));
Image kirby5 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/6.png"));
Image kirby6 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/5.png"));
Image kirby7 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/4.png"));
Image kirby8 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/3.png"));
Image kirby9 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/2.png"));
Image kirby10 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/1.png"));
animo = new Animacion();
animo.sumaCuadro(kirby0, 100);
animo.sumaCuadro(kirby1, 100);
animo.sumaCuadro(kirby2, 100);
animo.sumaCuadro(kirby3, 100);
animo.sumaCuadro(kirby4, 100);
animo.sumaCuadro(kirby5, 100);
animo.sumaCuadro(kirby6, 100);
animo.sumaCuadro(kirby7, 100);
animo.sumaCuadro(kirby8, 100);
animo.sumaCuadro(kirby9, 100);
animo.sumaCuadro(kirby10, 100);
} |
ba8d600f-052a-47a0-9d91-04c0c049099b | public static String getPAUSADO() {
return PAUSADO;
} |
d9d5ade1-92c1-4851-a363-5c2203d72e2b | public static String getDESAPARECE() {
return DESAPARECE;
} |
2ceda848-813e-4692-b41e-ec817a27718b | public SoundClip() {
try {
clip = AudioSystem.getClip();
} catch (LineUnavailableException e) {
System.out.println("Error en " + e.toString());
}
} |
08299003-32e3-4d03-9c43-e5fe0025c48e | public SoundClip(String filename) {
this();
load(filename);
} |
8312095b-c019-4222-9e4a-dd32cfaa9d53 | public void setLooping(boolean looping) {
this.looping = looping;
} |
1fb3874a-d448-4b75-b5a8-87f751556676 | public void setRepeat(int repeat) {
this.repeat = repeat;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.