:(
This commit is contained in:
@@ -17,5 +17,12 @@ Any value defined here will override the pom.xml file value but is only applicab
|
||||
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
|
||||
<org-netbeans-modules-projectapi.jsf_2e_language>JSP</org-netbeans-modules-projectapi.jsf_2e_language>
|
||||
<org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
|
||||
<netbeans.hint.jdkPlatform>JDK_11</netbeans.hint.jdkPlatform>
|
||||
<org-netbeans-modules-css-prep.less_2e_mappings>/less:/css</org-netbeans-modules-css-prep.less_2e_mappings>
|
||||
<org-netbeans-modules-css-prep.less_2e_enabled>false</org-netbeans-modules-css-prep.less_2e_enabled>
|
||||
<org-netbeans-modules-css-prep.sass_2e_enabled>false</org-netbeans-modules-css-prep.sass_2e_enabled>
|
||||
<org-netbeans-modules-css-prep.sass_2e_compiler_2e_options/>
|
||||
<org-netbeans-modules-css-prep.less_2e_compiler_2e_options/>
|
||||
<org-netbeans-modules-css-prep.sass_2e_mappings>/scss:/css</org-netbeans-modules-css-prep.sass_2e_mappings>
|
||||
</properties>
|
||||
</project-shared-configuration>
|
||||
|
@@ -7,6 +7,7 @@ package edu.slcc.asdv.beans;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.faces.view.ViewScoped;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@@ -17,19 +18,43 @@ import java.util.ArrayList;
|
||||
@ViewScoped
|
||||
public class MatrixBeanA implements Serializable
|
||||
{
|
||||
private int columns = 2;
|
||||
private int rows = 2;
|
||||
ArrayList<ArrayList<String>> matrix = new ArrayList<ArrayList<String>>();
|
||||
|
||||
public MatrixBeanA()
|
||||
{
|
||||
ArrayList<String> row1 = new ArrayList<String>();
|
||||
ArrayList<String> row2 = new ArrayList<String>();
|
||||
row1.add("1");
|
||||
row1.add("1");
|
||||
row2.add("3");
|
||||
row2.add("2");
|
||||
matrix = new ArrayList<ArrayList<String>>();
|
||||
matrix.add(row1);
|
||||
matrix.add(row2);
|
||||
BigInteger counter = BigInteger.ZERO;
|
||||
for (int i = 0; i < columns; ++i) {
|
||||
ArrayList<String> row = new ArrayList<>();
|
||||
for (int j = 0; j < rows; ++j) {
|
||||
counter = counter.add(BigInteger.ONE);
|
||||
System.out.println(counter.toString());
|
||||
row.add(counter.toString());
|
||||
}
|
||||
matrix.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
public int getColumns()
|
||||
{
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(int columns)
|
||||
{
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public int getRows()
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(int rows)
|
||||
{
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public void listenForKeyUp(int i, int j, String input)
|
||||
@@ -45,4 +70,26 @@ public class MatrixBeanA implements Serializable
|
||||
{
|
||||
return matrix;
|
||||
}
|
||||
public void changeRowsColumns() {
|
||||
System.out.println("Columns:" + columns);
|
||||
System.out.println("Rows:" + rows);
|
||||
ArrayList<ArrayList<String>> resizedMatrix = new ArrayList<>();
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
ArrayList<String> row = new ArrayList<>();
|
||||
for (int j = 0; j < columns; ++j) {
|
||||
row.add("1");
|
||||
}
|
||||
resizedMatrix.add(row);
|
||||
}
|
||||
// add the data from the old matrix to the new one
|
||||
for (int i = 0; i < columns; ++i) {
|
||||
for (int j = 0; j < rows; ++j) {
|
||||
if (i < matrix.size() && j < matrix.get(i).size()) {
|
||||
resizedMatrix.get(i).set(j, matrix.get(i).get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
// overwrite the old matrix
|
||||
matrix = resizedMatrix;
|
||||
}
|
||||
}
|
||||
|
@@ -7,9 +7,8 @@ package edu.slcc.asdv.beans;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.faces.view.ViewScoped;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import org.primefaces.PrimeFaces;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -19,20 +18,43 @@ import org.primefaces.PrimeFaces;
|
||||
@ViewScoped
|
||||
public class MatrixBeanB implements Serializable
|
||||
{
|
||||
|
||||
private int columns = 2;
|
||||
private int rows = 2;
|
||||
ArrayList<ArrayList<String>> matrix = new ArrayList<ArrayList<String>>();
|
||||
|
||||
public MatrixBeanB()
|
||||
|
||||
public MatrixBeanB()
|
||||
{
|
||||
ArrayList<String> row1 = new ArrayList<String>();
|
||||
ArrayList<String> row2 = new ArrayList<String>();
|
||||
row1.add("4");
|
||||
row1.add("5");
|
||||
row2.add("6");
|
||||
row2.add("7");
|
||||
matrix = new ArrayList<ArrayList<String>>();
|
||||
matrix.add(row1);
|
||||
matrix.add(row2);
|
||||
BigInteger counter = BigInteger.ZERO;
|
||||
for (int i = 0; i < columns; ++i) {
|
||||
ArrayList<String> row = new ArrayList<>();
|
||||
for (int j = 0; j < rows; ++j) {
|
||||
counter = counter.add(BigInteger.ONE);
|
||||
System.out.println(counter.toString());
|
||||
row.add(counter.toString());
|
||||
}
|
||||
matrix.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
public int getColumns()
|
||||
{
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(int columns)
|
||||
{
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public int getRows()
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(int rows)
|
||||
{
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public void listenForKeyUp(int i, int j, String input)
|
||||
@@ -40,11 +62,34 @@ public class MatrixBeanB implements Serializable
|
||||
System.out.println("i=" + i);
|
||||
System.out.println("j=" + j);
|
||||
System.out.println("input=" + input);
|
||||
matrix.get(i).set(j, input);
|
||||
matrix.get(i).set(j, input);
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<ArrayList<String>> getMatrix()
|
||||
{
|
||||
return matrix;
|
||||
}
|
||||
}
|
||||
public void changeRowsColumns() {
|
||||
System.out.println("Columns:" + columns);
|
||||
System.out.println("Rows:" + rows);
|
||||
ArrayList<ArrayList<String>> resizedMatrix = new ArrayList<>();
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
ArrayList<String> row = new ArrayList<>();
|
||||
for (int j = 0; j < columns; ++j) {
|
||||
row.add("1");
|
||||
}
|
||||
resizedMatrix.add(row);
|
||||
}
|
||||
// add the data from the old matrix to the new one
|
||||
for (int i = 0; i < columns; ++i) {
|
||||
for (int j = 0; j < rows; ++j) {
|
||||
if (i < matrix.size() && j < matrix.get(i).size()) {
|
||||
resizedMatrix.get(i).set(j, matrix.get(i).get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
// overwrite the old matrix
|
||||
matrix = resizedMatrix;
|
||||
}
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ package edu.slcc.asdv.beans;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.faces.view.ViewScoped;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -18,32 +18,84 @@ import java.util.Arrays;
|
||||
@ViewScoped
|
||||
public class MatrixBeanC implements Serializable
|
||||
{
|
||||
|
||||
private int columns = 2;
|
||||
private int rows = 2;
|
||||
ArrayList<ArrayList<String>> matrix = new ArrayList<ArrayList<String>>();
|
||||
|
||||
|
||||
public MatrixBeanC()
|
||||
|
||||
public MatrixBeanC()
|
||||
{
|
||||
ArrayList<String> row1 = new ArrayList<String>();
|
||||
ArrayList<String> row2 = new ArrayList<String>();
|
||||
row1.add("-1");
|
||||
row1.add("-1");
|
||||
row2.add("-1");
|
||||
row2.add("-1");
|
||||
matrix = new ArrayList<ArrayList<String>>();
|
||||
matrix.add(row1);
|
||||
matrix.add(row2);
|
||||
BigInteger counter = BigInteger.ZERO;
|
||||
for (int i = 0; i < columns; ++i) {
|
||||
ArrayList<String> row = new ArrayList<>();
|
||||
for (int j = 0; j < rows; ++j) {
|
||||
counter = counter.add(BigInteger.ONE);
|
||||
System.out.println(counter.toString());
|
||||
row.add(counter.toString());
|
||||
}
|
||||
matrix.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
public int getColumns()
|
||||
{
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(int columns)
|
||||
{
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public int getRows()
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(int rows)
|
||||
{
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public void listenForKeyUp(int i, int j, String input)
|
||||
{
|
||||
System.out.println("i=" + i);
|
||||
System.out.println("j=" + j);
|
||||
System.out.println("input=" + input);
|
||||
matrix.get(i).set(j, input);
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<ArrayList<String>> getMatrix()
|
||||
{
|
||||
return matrix;
|
||||
}
|
||||
public void setMatrixC(ArrayList<ArrayList<String>> matrix)
|
||||
|
||||
public void setMatrix(ArrayList<ArrayList<String>> matrix)
|
||||
{
|
||||
this.matrix = matrix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void changeRowsColumns() {
|
||||
System.out.println("Columns:" + columns);
|
||||
System.out.println("Rows:" + rows);
|
||||
ArrayList<ArrayList<String>> resizedMatrix = new ArrayList<>();
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
ArrayList<String> row = new ArrayList<>();
|
||||
for (int j = 0; j < columns; ++j) {
|
||||
row.add("1");
|
||||
}
|
||||
resizedMatrix.add(row);
|
||||
}
|
||||
// add the data from the old matrix to the new one
|
||||
for (int i = 0; i < columns; ++i) {
|
||||
for (int j = 0; j < rows; ++j) {
|
||||
if (i < matrix.size() && j < matrix.get(i).size()) {
|
||||
resizedMatrix.get(i).set(j, matrix.get(i).get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
// overwrite the old matrix
|
||||
matrix = resizedMatrix;
|
||||
}
|
||||
}
|
||||
|
@@ -30,14 +30,28 @@ public class MatrixOperations implements Serializable
|
||||
|
||||
edu.slcc.asdv.bl.Matrices matrixManipulator = new edu.slcc.asdv.bl.Matrices();
|
||||
|
||||
public String add(){
|
||||
ArrayList<ArrayList<BigInteger>> a = convertToBigInteger(matrixA.getMatrix());
|
||||
ArrayList<ArrayList<BigInteger>> b = convertToBigInteger(matrixA.getMatrix());
|
||||
public String add() {
|
||||
|
||||
ArrayList<ArrayList<String>> a = matrixA.getMatrix();
|
||||
ArrayList<ArrayList<String>> b = matrixB.getMatrix();
|
||||
ArrayList<ArrayList<String>> c = new ArrayList<ArrayList<String>>();
|
||||
c = convertToString(matrixManipulator.addParallel(a, b));
|
||||
printArray(c);
|
||||
matrixC.setMatrixC( c );
|
||||
return "";
|
||||
|
||||
for ( int i=0; i < a.size(); ++i)
|
||||
{
|
||||
ArrayList<String> row = new ArrayList<>();
|
||||
for ( int j=0; j < a.size(); ++j)
|
||||
{
|
||||
Integer result = Integer.parseInt ( a.get(i).get(j))
|
||||
+
|
||||
Integer.parseInt ( b.get(i).get(j));
|
||||
|
||||
row.add( result.toString() );
|
||||
}
|
||||
c.add(row);
|
||||
System.out.println(row);
|
||||
}
|
||||
matrixC.setMatrix( c );
|
||||
return "";
|
||||
}
|
||||
|
||||
public String multiply() {
|
||||
@@ -46,17 +60,32 @@ public class MatrixOperations implements Serializable
|
||||
ArrayList<ArrayList<String>> c = new ArrayList<ArrayList<String>>();
|
||||
c = convertToString(matrixManipulator.multiplyParallel(a, b));
|
||||
printArray(c);
|
||||
matrixC.setMatrixC( c );
|
||||
matrixC.setMatrix( c );
|
||||
return "";}
|
||||
|
||||
public String subtract() {
|
||||
ArrayList<ArrayList<BigInteger>> a = convertToBigInteger(matrixA.getMatrix());
|
||||
ArrayList<ArrayList<BigInteger>> b = convertToBigInteger(matrixA.getMatrix());
|
||||
|
||||
ArrayList<ArrayList<String>> a = matrixA.getMatrix();
|
||||
ArrayList<ArrayList<String>> b = matrixB.getMatrix();
|
||||
ArrayList<ArrayList<String>> c = new ArrayList<ArrayList<String>>();
|
||||
c = convertToString(matrixManipulator.subtractParallel(a, b));
|
||||
printArray(c);
|
||||
matrixC.setMatrixC( c );
|
||||
return "";}
|
||||
|
||||
for ( int i=0; i < a.size(); ++i)
|
||||
{
|
||||
ArrayList<String> row = new ArrayList<>();
|
||||
for ( int j=0; j < a.size(); ++j)
|
||||
{
|
||||
Integer result = Integer.parseInt ( a.get(i).get(j))
|
||||
-
|
||||
Integer.parseInt ( b.get(i).get(j));
|
||||
|
||||
row.add( result.toString() );
|
||||
}
|
||||
c.add(row);
|
||||
System.out.println(row);
|
||||
}
|
||||
matrixC.setMatrix( c );
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public MatrixBeanC getMatrixC(){return this.matrixC;}
|
||||
@@ -65,6 +94,8 @@ public class MatrixOperations implements Serializable
|
||||
|
||||
public MatrixBeanB getMatrixB(){return matrixB;}
|
||||
|
||||
/*
|
||||
|
||||
public ArrayList<ArrayList<BigInteger>> convertToBigInteger(ArrayList<ArrayList<String>> matrix) {
|
||||
ArrayList<ArrayList<BigInteger>> bigInt2DArray = new ArrayList<>();
|
||||
|
||||
@@ -94,7 +125,7 @@ public class MatrixOperations implements Serializable
|
||||
}
|
||||
return string2DArray;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @param matrix
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
</h:head>
|
||||
<h:body>
|
||||
<h:form id="form_matrix_A">
|
||||
<h:form id="form_matrix_A">
|
||||
<p:tooltip globalSelector="true"/>
|
||||
<p:growl id="id_messageA" showDetail="true"/>
|
||||
|
||||
@@ -32,18 +32,22 @@
|
||||
value="#{matrixOperations.getMatrixA().getMatrix().get(i)}"
|
||||
var="arrayListElement" columnIndexVar="j">
|
||||
<h:inputText
|
||||
|
||||
|
||||
converterMessage="Invalid format!"
|
||||
title= "(#{i},#{j})"
|
||||
style="margin-left: 2px;" class="input"
|
||||
value="#{row[i]}" >
|
||||
value="#{row[j]}" >
|
||||
<f:ajax event="keyup"
|
||||
listener="#{matrixOperations.getMatrixA().listenForKeyUp(i,j, row[i] )}"
|
||||
/>
|
||||
listener="#{matrixOperations.getMatrixA().listenForKeyUp(i,j, row.get(j) )}"/>
|
||||
</h:inputText>
|
||||
</p:columns>
|
||||
|
||||
|
||||
<f:facet name="footer">
|
||||
columns:
|
||||
<h:inputText id="columns" value="#{matrixOperations.getMatrixA().columns}"/>
|
||||
rows:
|
||||
<h:inputText id="rows" value="#{matrixOperations.getMatrixA().rows}"/>
|
||||
<h:commandButton value="Change Sizes" action="#{matrixOperations.getMatrixA().changeRowsColumns()}"/>
|
||||
</f:facet>
|
||||
</p:dataTable>
|
||||
</h:form>
|
||||
</h:body>
|
||||
|
@@ -33,13 +33,18 @@
|
||||
converterMessage="Invalid format!"
|
||||
title= "(#{i},#{j})"
|
||||
style="margin-left: 2px;" class="input"
|
||||
value="#{row[i]}" >
|
||||
<f:ajax event="keyup"
|
||||
listener="#{matrixOperations.getMatrixB().listenForKeyUp(i,j, row[i] )}"
|
||||
/>
|
||||
value="#{row[j]}" >
|
||||
<f:ajax event="keyup"
|
||||
listener="#{matrixOperations.getMatrixB().listenForKeyUp(i,j, row.get(j) )}"/>
|
||||
</h:inputText>
|
||||
</p:columns>
|
||||
|
||||
<f:facet name="footer">
|
||||
columns:
|
||||
<h:inputText id="columns" value="#{matrixOperations.getMatrixB().columns}"/>
|
||||
rows:
|
||||
<h:inputText id="rows" value="#{matrixOperations.getMatrixB().rows}"/>
|
||||
<h:commandButton value="Change Sizes" action="#{matrixOperations.getMatrixB().changeRowsColumns()}"/>
|
||||
</f:facet>
|
||||
|
||||
</p:dataTable>
|
||||
</h:form>
|
||||
|
@@ -33,11 +33,17 @@
|
||||
converterMessage="Invalid format!"
|
||||
title= "(#{i},#{j})"
|
||||
style="margin-left: 2px;" class="input"
|
||||
value="#{row[i]}" >
|
||||
value="#{row[j]}" >
|
||||
|
||||
</h:inputText>
|
||||
</p:columns>
|
||||
|
||||
<f:facet name="footer">
|
||||
columns:
|
||||
<h:inputText id="columns" value="#{matrixOperations.getMatrixC().columns}"/>
|
||||
rows:
|
||||
<h:inputText id="rows" value="#{matrixOperations.getMatrixC().rows}"/>
|
||||
<h:commandButton value="Change Sizes" action="#{matrixOperations.getMatrixC().changeRowsColumns()}"/>
|
||||
</f:facet>
|
||||
|
||||
</p:dataTable>
|
||||
</h:form>
|
||||
|
Reference in New Issue
Block a user