您可以将代码转换为仅C#方法(不是设计部分)吗? [英] Could you convert the code into C# only methods (not the design part)
本文介绍了您可以将代码转换为仅C#方法(不是设计部分)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
/*
* ClusterForm.java
*
* Created on September 20, 2010, 2:53 PM
*/
package ctrend;
import javax.swing.*;
import java.awt.*;
import java.util.*;
/**
*
* @author Raja
*/
public class ClusterForm extends javax.swing.JFrame {
/** Creates new form ClusterForm */
FlowLayout layout=new FlowLayout();
DataSet ds;
ArrayList<String>coldata;
ClusterBean cbean;
public ClusterForm() {
initComponents();
ds=new DataSet();
coldata=ds.loadFields();
cmbColNames.removeAllItems();
for(int i=0;i<coldata.size();i++)
cmbColNames.addItem(coldata.get(i).toUpperCase());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
cmbColNames = new javax.swing.JComboBox();
butSubmit = new javax.swing.JButton();
butShowTimePeriods = new javax.swing.JButton();
butShowGraph = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel1.setText("Select Time Related Field");
butSubmit.setText("Submit");
butSubmit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
butSubmitActionPerformed(evt);
}
});
butShowTimePeriods.setText("Show Time Periods");
butShowTimePeriods.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
butShowTimePeriodsActionPerformed(evt);
}
});
butShowGraph.setText("Show Graph");
butShowGraph.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
butShowGraphActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addContainerGap(745, Short.MAX_VALUE))
.addComponent(butSubmit)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(cmbColNames, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(762, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(butShowTimePeriods)
.addContainerGap(766, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(butShowGraph)
.addContainerGap(796, Short.MAX_VALUE))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmbColNames, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(8, 8, 8)
.addComponent(butSubmit)
.addGap(15, 15, 15)
.addComponent(butShowTimePeriods)
.addGap(17, 17, 17)
.addComponent(butShowGraph)
.addContainerGap(70, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(278, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void butShowGraphActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butShowGraphActionPerformed
buildGraph();
GraphPanel.tp=cbean.tp;
System.out.println("TP SIZE:"+cbean.tp.size());
JFrame frm=new JFrame();
frm.setTitle("C-TREND Temporal Graph Model");
frm.setBackground(Color.black);
GraphPanel gp=new GraphPanel();
frm.add(gp);
frm.setSize(800,600);
frm.setVisible(true);
frm.setDefaultCloseOperation(frm.DISPOSE_ON_CLOSE);
}//GEN-LAST:event_butShowGraphActionPerformed
private void butShowTimePeriodsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butShowTimePeriodsActionPerformed
for(int i=0;i<cbean.tp.size();i++)
{
TimePeriod curtp=cbean.tp.get(i);
curtp.findMedioids();
curtp.showMedioids();
}
}//GEN-LAST:event_butShowTimePeriodsActionPerformed
public void buildGraph()
{
int row,col;
col=100;
for(int i=0;i<cbean.tp.size();i++)
{
TimePeriod curtp=cbean.tp.get(i);
row=50;
for(int j=0;j<curtp.centroids.size();j++,row+=100)
{
DataObject curcentroid=curtp.centroids.get(j);
curcentroid.xc=col;
curcentroid.yc=row;
System.out.println(curcentroid.xc+","+curcentroid.yc);
}
col+=400;
}
}
private void butSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butSubmitActionPerformed
try
{
DataSet ds=new DataSet();
int colidx=cmbColNames.getSelectedIndex();
System.out.println("Selected Idx:"+colidx);
ds.buildTables();
cbean=new ClusterBean();
cbean.buildClusters(colidx);
//ds.loadField(colidx);
}catch(Exception e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null,e.toString());
}
}//GEN-LAST:event_butSubmitActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ClusterForm().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton butShowGraph;
private javax.swing.JButton butShowTimePeriods;
private javax.swing.JButton butSubmit;
private javax.swing.JComboBox cmbColNames;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
// End of variables declaration//GEN-END:variables
}
推荐答案
为什么有人会为您做这项工作(免费)? :confused:如果在将某些内容转换为C#时遇到特定问题,则可以查明问题并寻求帮助以解决该问题.如果您要自己维护代码,那么也必须了解C#代码的作用.
Why would someone do the work for you (for free)? :confused: If you have specific problems in translating certain thing to C#, you could pinpoint the problem and ask for help to solve that issue. If you''re going to maintain the code by yourself it''s crucial that you also understand what the C# code does.
看看 ^ ].
那里有更多的负载,有些比其他负载要好.我不知道这有多好,这只是从 java到c#转换器的搜索中的第一击
我怀疑他们中的任何一个都做得很好,所以您将必须学习一些C#才能完成这项工作.
Take a look here[^].
There are loads more out there, some better than others. I have no idea how good this one is, it is just the first hit from a search on java to c# converter
I doubt that any of them will do a perfect job though, so you''re going to have to learn some C# to complete the job.
这篇关于您可以将代码转换为仅C#方法(不是设计部分)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文