id
stringlengths
36
36
text
stringlengths
1
1.25M
78a0e34e-4d26-4822-82e2-1101c0ac174b
public void setVirada(boolean virada) { this.virada = virada; }
87b9dc59-b467-4f8c-b545-af74627eac72
public int getCodigo() { return codigo; }
85846ccd-5c4c-4c3e-9aba-060d2eddd24b
public void setCodigo(int id) { this.codigo = id; }
d551aa19-5f0a-4b42-a2fe-8f4c68e17ca4
public void setPosicao(int x, int y){ this.x = x; this.y = y; }
bcb2fbc7-0dc7-412f-961d-38b5def63eea
public static void main(String[] args) { testInicializarJogoCampoVazio(); }
512baac8-435b-4108-ab44-59ec965ae9d7
public static void testGravarJogador() { //assertFalse(fachada.existeJogador()); System.out.println(fachada.existeJogador()); fachada.salvarJogador("nome"); //assertTrue(fachada.existeJogador()); System.out.println(fachada.existeJogador()); }
ebea5dc7-7cdd-480a-a32a-d11732aa9707
public static void testInicializarJogoCampoVazio(){ fachada.salvarJogador("nome"); //assertTrue(fachada.existeJogador()); System.out.println("jogador criado: "+fachada.existeJogador()); fachada.iniciarJogo(); System.out.println("jogo iniciado"); //For que vai percorrer todo o tabuleiro for(int i = 0 ; ...
ac77f63c-b20b-4f11-b353-fbed7e97e10a
public static void testInicializarJogoCartaRepetida(){ fachada.salvarJogador("berg"); fachada.existeJogador(); //fachada.iniciarJogo(); int[] list = new int[6]; int cont = 0; for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 4 ; j++){ int codigo = fachada.getCartaTabuleiro(i,j).getCodigo(); li...
cde81c14-546a-42b6-b949-dca5c3fdb0df
public ExampleFileFilter() { this.filters = new Hashtable(); }
35af50d2-bc06-46c4-a07e-57803dba181f
public ExampleFileFilter(String extension) { this(extension,null); }
1ccf2d00-d76f-4555-a569-e240354c617c
public ExampleFileFilter(String extension, String description) { this(); if(extension!=null) addExtension(extension); if(description!=null) setDescription(description); }
4376e29b-9c72-4803-8cd4-15924223624e
public ExampleFileFilter(String[] filters) { this(filters, null); }
b66678ea-f300-4ccd-bfdc-ec52cc282894
public ExampleFileFilter(String[] filters, String description) { this(); for (int i = 0; i < filters.length; i++) { // add filters one by one addExtension(filters[i]); } if(description!=null) setDescription(description); }
23757155-d047-47e2-b856-e57aa95e5b40
public boolean accept(File f) { if(f != null) { if(f.isDirectory()) { return true; } String extension = getExtension(f); if(extension != null && filters.get(getExtension(f)) != null) { return true; }; } return false; }
67babc87-c50a-458a-8b8a-2ca3ef7dfc2a
public String getExtension(File f) { if(f != null) { String filename = f.getName(); int i = filename.lastIndexOf('.'); if(i>0 && i<filename.length()-1) { return filename.substring(i+1).toLowerCase(); }; } return null; }
962dfd0e-dc51-493e-8f5b-8578198c7d9b
public void addExtension(String extension) { if(filters == null) { filters = new Hashtable(5); } filters.put(extension.toLowerCase(), this); fullDescription = null; }
9b349ccd-3eae-4c3a-b558-0a75dd865949
public String getDescription() { if(fullDescription == null) { if(description == null || isExtensionListInDescription()) { fullDescription = description==null ? "(" : description + " ("; // build the description from the extension list Enumeration extensions = filters.keys(); if(extensions != null) { ...
606b2766-13bd-4c22-8109-68b5bcf401cd
public void setDescription(String description) { this.description = description; fullDescription = null; }
a01c3980-458c-4153-826a-2eda4e555ae0
public void setExtensionListInDescription(boolean b) { useExtensionsInDescription = b; fullDescription = null; }
a5f28a4a-be5b-47b1-aef1-b6955658c216
public boolean isExtensionListInDescription() { return useExtensionsInDescription; }
f3f32ff6-57ae-406f-ae7d-ff85e25ff2e7
public PrintStream(java.io.InputStream is) { __is = is; }
1638e1b8-9ab9-45c4-8e83-263ea2c1643a
public void run() { try { while(this != null) { int _ch = __is.read(); if(_ch != -1) System.out.print((char)_ch); // System.out.print('m'); } else break; ...
ab611c8a-067a-40c1-a6d6-ab8374262f25
static void getPath() { // �Ȼ�ȡ��ǰ��Ŀ·�����ڻ��Դ�ļ���Ŀ���ļ���ת������·�� File diretory = new File(""); try { String currPath = diretory.getAbsolutePath(); //inputPath = currPath + "\\input\\"; outputPath = "D:\\ffmpeg\\output\\"; ffmpegPath = currPat...
2dcb22c0-4d60-420b-984d-332843e3242b
static String process() { int type = checkContentType(); String status = ""; if (type == 0) { System.out.println("直接转换"); status = processMulti(inputPath);// ֱ��ת��flv��ʽ //String avifilepath = processAVI(type); } else if (type == 1) { ...
1caadfde-97fe-4ef4-818e-1055b5250e8a
static int checkContentType() { String type = inputPath.substring(inputPath.lastIndexOf(".") + 1, inputPath.length()) .toLowerCase(); // ffmpeg�ܽ����ĸ�ʽ����asx��asf��mpg��wmv��3gp��mp4��mov��avi��flv�ȣ� if (type.equals("avi")) { return 0; } else if (type...
3aba895b-60d1-4d62-bfdc-3b445b192769
static boolean checkfile(String path) { File file = new File(path); if (!file.isFile()) { return false; } return true; }
4f77d7fd-46d8-45e7-807d-47295ac418ea
static String processAVI(int type) { List<String> commend = new ArrayList<String>(); commend.add(ffmpegPath + "mencoder"); commend.add(inputPath); commend.add("-oac"); commend.add("mp3lame"); commend.add("-lameopts"); commend.add("preset=64"); comm...
a37f08a1-a3fa-4037-89d2-b6c273369018
public void run() { BufferedReader br = new BufferedReader( new InputStreamReader(is1)); try { String lineB = null; while ((lineB = br.readLine()) != null ){ if(lineB != null) ...
90ff777e-2678-4488-b1ee-d2c9d9b01991
public void run() { BufferedReader br2 = new BufferedReader( new InputStreamReader(is2)); try { String lineC = null; while ( (lineC = br2.readLine()) != null){ //if(lineC != null) ...
8254bf7d-a238-40d5-8c3a-01a71f80fa24
static String processMulti(String oldfilepath) { int d = 0; String time= ""; String st1 = ""; String st2 = ""; int resultMulti = 0; int ct = 0; String[] r = inputPath.split("\\\\"); st1 = r[r.length - 2]; //视频上层目录 st2 = r[r.leng...
62e656ca-dbef-4e69-bb23-444d6b1327bb
static String analysis(String oldfilepath) { if (!checkfile(inputPath)) { System.out.println(oldfilepath + " is not file"); return null; } //System.out.println(oldfilepath+"analysis"); List<String> command = new ArrayList<String>(); ...
77f54171-0744-4fbd-9f72-d34c0f87153d
static void screenshot(String name,int time,int timeall) { if (!checkfile(name)) { System.out.println(name + " is not file"); return; } List<String> command = new ArrayList<String>(); command.add(ffmpegPath + "ffmpeg"); command....
df850a81-414f-4e39-82a3-f559b6ffe0b5
static String secToTime(int time) { String timeStr = null; int hour = 0; int minute = 0; int second = 0; if (time <= 0) return "00:00"; else { minute = time / 60; if (minute < 60) { second =...
1d3963a7-fa02-4d1f-a587-767f302912a9
static String unitFormat(int i) { String retStr = null; if (i >= 0 && i < 10) retStr = "0" + Integer.toString(i); else retStr = "" + i; return retStr; }
12a805b9-b074-454e-9281-fb8c0393f354
static int timeToSec(String str) { int index1 = 0; int index2 = 0; int hh = 0; int mi = 0; int ss = 0; index1=str.indexOf(":"); index2=str.indexOf(":",index1+1); hh=Integer.parseInt(str.substring(0,index1)); mi=Integer.parseInt(str.substri...
73deafcf-da44-485b-8eee-a2e9ea6b34f8
static String changeSize(String s,int i) { String s1 = s.substring(s.indexOf("x")+1); int i1 = Integer.parseInt(s1.trim()); if(i1>i){ String s0 = s.substring(0,s.indexOf("x")); int i0 = Integer.parseInt(s0.trim()); i0 = (int) (i0/(i1/(i*1.0))...
a170e8be-5216-43b7-b3fa-4f0c163bad78
public void run() { jButton1.setEnabled(false); //“浏览”按钮变灰 jButton2.setEnabled(false); //“开始”按钮变灰 if(name.size() != 0) { OutputStream out = null; try { sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); ...
8c0358b2-8c8f-44eb-8d94-c0650f840a09
public Videoview() { this.setResizable(false); initComponents(); }
f232c069-3c6f-4d3a-b2e7-e66ba94d777a
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jCheckBox1 = new javax.swing.JCheckBox(); jCheckBox2 = new javax.swing.JCheckBox(); jCheckBox3 = new javax.swing.JCheckBox(); ...
488da458-3543-4f47-98b6-ab247341b5eb
public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox1ActionPerformed(evt); }
9c9360ed-e7b4-4ed9-997f-e2f895432b60
public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox2ActionPerformed(evt); }
ad30a697-bb55-4555-88cd-a40e3ef93046
public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox3ActionPerformed(evt); }
9ea383e0-d503-46b4-baeb-2da398fcd14a
public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox4ActionPerformed(evt); }
0e4f3be6-53a3-4bbb-9f25-5a4b29361f87
public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox5ActionPerformed(evt); }
74bd070a-69a3-4c55-aba6-480d2b83bb88
public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); }
249d6e82-8401-49e9-8ee0-71793e98cd2e
public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); }
a37337c6-d12c-442d-a357-63563c90dcb7
public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); }
da3d8f07-f1fa-49b4-8870-49713fda8a40
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed name.clear(); //点击“浏览”按钮,清除已选歌曲 count = 0 ; int r = tableModel.getRowCount(); for(int e = 0;e<r;e++) tableModel.removeRow(0); JFileChooser chooser ...
0585ba42-2be3-424c-8588-b893d7d96c9b
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed height = 240; jCheckBox2.setSelected(false); jCheckBox3.setSelected(false); jCheckBox4.setSelected(false); jCheckBox5.setSelected(false); }
a5666d69-4dd6-4458-b90f-0285264e6dd0
private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed height = 360; jCheckBox1.setSelected(false); jCheckBox3.setSelected(false); jCheckBox4.setSelected(false); jCheckBox5.setSelected(false); }
d323262f-df7a-4aca-8242-b1a06960ec83
private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed height = 480; jCheckBox1.setSelected(false); jCheckBox2.setSelected(false); jCheckBox4.setSelected(false); jCheckBox5.setSelected(false); }
eab3ab2d-48dd-439a-9e21-ac8e6da27edb
private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed height = 720; jCheckBox1.setSelected(false); jCheckBox2.setSelected(false); jCheckBox3.setSelected(false); jCheckBox5.setSelected(false); }
77eb2658-aa75-4601-bb7b-2311f4e82a69
private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed height = 1080; jCheckBox1.setSelected(false); jCheckBox2.setSelected(false); jCheckBox3.setSelected(false); jCheckBox4.setSelected(false); }
7cd74a8e-a764-4037-a520-55e0f4180187
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed jButton2.setEnabled(false); //点击“开始”按钮,“开始”按钮变灰 flag = false; //“暂停”标志,为“真”时是暂停状态 if(start==false&&name.size()!=0){ start = true; //“开始”标志,为“真”时表示点击过“开始”按钮 But...
daa8f524-1bbc-4e4c-a977-48e051d1cf25
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { flag = true; //设置“暂停”标志为“真” jButton2.setEnabled(true); //设置“开始”按钮可见 }//GEN-LAST:event_jButton2ActionPerformed
9ae15584-4ac7-434c-9eb7-29f5ad4faad2
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
2639dcfb-97d2-4ca9-87d1-032ac50b1811
public void run() { new Videoview().setVisible(true); }
26cf7fc9-f185-4912-82c6-dce0f8a94a55
public Resource(String name) { this.name = name; activeProcess = null; setBackground(Color.white); }
796529ee-976f-46b1-88da-205989ffb9c3
public void setActiveProcess(Process p) { activeProcess = p; repaint(); }
5eabb756-e045-435e-a3cb-7b31aa9519b0
public void paintComponent(Graphics g) { super.paintComponent(g); int w = getWidth()-1; int h = getHeight()-1; g.setColor(Color.red); g.drawOval(0,0,w,h); g.setColor(Color.black); g.setFont(font); FontMetrics fm = g.getFontMetrics(font); g.drawString(name, w/2-fm.stringWidth(name)/2, h/2-10); if(act...
70869167-0cdb-4880-baf3-2ebb87a6a0fb
public PicturePanel(Image image) { super(); this.image = image; orientation = SOUTH; setOpaque(false); }
e72551e8-b298-4044-bd92-f369b4c134fa
public void setTopImage(Image newTop) { topImage = newTop; }
134a527c-f7f2-448c-a965-fb6009e108ca
public void setOrientation(int or){ orientation = or; }
239c7b28-9fa5-4fa2-9b62-c49c8f0bf6c6
public Dimension getPreferredSize() { return new Dimension(imageWidth, imageHeight); }
7737de8e-7d71-4548-8cf6-7a046906d18a
public void setBounds(int x, int y, int w, int h) { super.setBounds(x,y,w,h); imageWidth = w; imageHeight = h; }
7a62d1b3-70bb-4ef8-9d2b-997f898ad88e
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2D = (Graphics2D) g; if(orientation > 0) g2D.rotate(Math.PI*orientation/2.0, imageWidth/2.0, imageHeight/2.0); g.drawImage(image,0,0,imageWidth,imageHeight,this); if(topImage != null) g2D.drawImage(topImage,0,0,imageWidth,imag...
da39ba7d-f90d-453c-99fa-31357c30f040
public void printReport(long simulationLength) { System.out.println(); System.out.println("Simulation statistics:"); System.out.println(); System.out.println("Number of completed processes: "+nofCompletedProcesses); System.out.println("Number of created processes: ...
fbbe242d-b47c-4c16-8313-db8b3431298d
public Queue(String name, int maxVisibleLength, int direction) { this.name = name; this.maxVisibleLength = maxVisibleLength; this.direction = direction; content = new ArrayList(); setBackground(Color.white); }
6a9ba8ba-c246-4bda-9c73-1faa86d93d4f
public void insert(Object o) { content.add(o); repaint(); }
5ba8fffe-4b4f-4c7e-953e-3a6570275b61
public Object getNext() { return content.get(0); }
db3991af-fa9c-4616-87c9-3a60948aa14f
public Object removeNext() { Object result = content.remove(0); repaint(); return result; }
c6e73f02-dd7d-4212-89aa-f7b7b8de71de
public boolean isEmpty() { return content.size() == 0; }
51c1c818-91ff-422f-9883-9c6dc8bd6b6e
public int getQueueLength() { return content.size(); }
04aeabab-b919-469f-813d-59ec9960b91e
public void paintComponent(Graphics g) { super.paintComponent(g); int w = getWidth()-1; int h = getHeight()-1; g.setFont(font); FontMetrics fm = g.getFontMetrics(font); String heading = "Items in "+name+": "+content.size(); switch(direction) { case EAST: g.setColor(Color.black); g.drawString(headi...
5988abdb-ceb0-4ec7-bd41-16b7d2990606
public Memory(Queue memoryQueue, long memorySize, Statistics statistics) { this.memoryQueue = memoryQueue; this.memorySize = memorySize; this.statistics = statistics; freeMemory = memorySize; }
b5ef1185-07c1-47c6-8364-ab691cc07e4d
public long getMemorySize() { return memorySize; }
181d4cfd-2968-4e51-bc57-bd203a0bb064
public void insertProcess(Process p) { memoryQueue.insert(p); }
bb85dab4-f602-4529-8f4b-6898a0b20cc7
public Process checkMemory(long clock) { if(!memoryQueue.isEmpty()) { Process nextProcess = (Process)memoryQueue.getNext(); if(nextProcess.getMemoryNeeded() <= freeMemory) { // Allocate memory to this process freeMemory -= nextProcess.getMemoryNeeded(); nextProcess.leftMemoryQueue(clock); memor...
fddd1f8a-a294-4d67-9b21-aa5624a56f16
public void timePassed(long timePassed) { statistics.memoryQueueLengthTime += memoryQueue.getQueueLength()*timePassed; if (memoryQueue.getQueueLength() > statistics.memoryQueueLargestLength) { statistics.memoryQueueLargestLength = memoryQueue.getQueueLength(); } }
7a2bf5be-c224-4c49-9c08-8bdf9a534263
public void processCompleted(Process p) { freeMemory += p.getMemoryNeeded(); }
90634ce1-cbe3-45f0-bd97-577a3e8cdef6
public CPU(Queue cpuQueue, Gui gui, long maxCpuTime, Statistics statistics){ this.cpuQueue = cpuQueue; this.gui = gui; this.maxCpuTime = maxCpuTime; this.statistics = statistics; this.activeProcess = null; }
08d127b9-84c1-489d-9fc4-8dbc5f5ee67a
public void addProcess(Process process){ statistics.nofTimesInCpuQue++; cpuQueue.insert(process); }
94252e7e-62a0-4c76-b76a-3f90278bdbdb
public Process removeProcess(){ if(!cpuQueue.isEmpty()){ Process process = (Process) cpuQueue.removeNext(); return process; } return null; }
b6ade3d4-7e0b-4813-b3a9-058f68398640
public Boolean isIdle(){ return this.activeProcess==null; }
ba26de31-8904-4340-92cf-096bd19f2806
public Process getActiveProcess(){ Process process = this.activeProcess; this.activeProcess = null; return process; }
3b98aea3-563e-4602-9408-4385e5a47fc5
public Process startNextProcess(){ if(cpuQueue.isEmpty()){ this.activeProcess = null; gui.setCpuActive(activeProcess); } else{ this.activeProcess = removeProcess(); gui.setCpuActive(activeProcess); } return this.activeProcess; }
ea1bcacc-8a58-4e64-af66-c17bd2d17e5c
public long getMaxCpuTime() { return this.maxCpuTime; }
3f819bb7-c0ae-45c7-8640-955bdf063d44
public void timePassed(long timePassed) { statistics.cpuQueueLengthTime += cpuQueue.getQueueLength()*timePassed; if (cpuQueue.getQueueLength() > statistics.CpuQueueLargestLength) { statistics.CpuQueueLargestLength = cpuQueue.getQueueLength(); } }
56732c69-ada1-4269-977a-3efde4928e4c
public EventQueue() { events = new ArrayList(); }
32b4d338-c4cd-4f85-af2e-b891d4beb998
public void insertEvent(Event event) { if(event != null) { events.add(event); Collections.sort(events); } }
034d77a0-e6fd-4094-950b-bc8bcf71bd4e
public Event getNextEvent() { return (Event)events.remove(0); }
d175718a-4c5f-407b-a77a-ef7eba386574
public boolean isEmpty() { return events.size() == 0; }
c3150908-62f5-480e-a95e-99ee4f4a8a51
public Event(int type, long time) { this.type = type; this.time = time; }
cbda7cb7-4b47-418f-9a93-0cb4a30082d7
public int getType() { return type; }
f6dcc9fc-9fc7-48fa-b6fc-a40442a41fef
public long getTime() { return time; }
23ab7115-93c4-43bb-be0b-957a0b235645
public int compareTo(Object o) { Event e = (Event)o; return (int)(time-e.time); }
5116303f-c5dc-44e8-9e78-584ce688de8f
public Simulator(Queue memoryQueue, Queue cpuQueue, Queue ioQueue, long memorySize, long maxCpuTime, long avgIoTime, long simulationLength, long avgArrivalInterval, Gui gui) { this.simulationLength = simulationLength; this.avgArrivalInterval = avgArrivalInterval; this.gui = gui; statistics = new Statistics()...
9861ada1-f55b-4755-9925-7be00122f54a
public void simulate() { // TODO: You may want to extend this method somewhat. System.out.print("Simulating..."); // Genererate the first process arrival event eventQueue.insertEvent(new Event(NEW_PROCESS, 0)); // Process events until the simulation length is exceeded: while (clock < simulationLength && !e...
a6f2d78f-3668-40c0-ba72-6e000ef0b719
private void processEvent(Event event) { switch (event.getType()) { case NEW_PROCESS: createProcess(); break; case SWITCH_PROCESS: switchProcess(); break; case END_PROCESS: endProcess(); break; case IO_REQUEST: processIoRequest(); break; case END_IO: endIoOperation()...
98d0496a-2932-4393-8fe9-1141be8ef4d3
private void createProcess() { // Create a new process Process newProcess = new Process(memory.getMemorySize(), clock); memory.insertProcess(newProcess); // Add an event for the next process arrival long nextArrivalTime = clock + 1 + (long)(2*Math.random()*avgArrivalInterval); eventQueue.insertEvent(new Eve...