Package sw_digitalworks.Model

Examples of sw_digitalworks.Model.Composit


                                OutComponent.getName(),
                                outPortNumber));

                        Component ocomp = Main.Components.get(OutComponentName);
                        Component icomp = Main.Components.get(InComponentName);
                        Composit comp = ocomp.GetComposit();
                        if (comp != null) {
                            int ocn = comp.GetComponents().indexOf(ocomp);
                            int icn = comp.GetComponents().indexOf(icomp);
                            comp.addConnection(ocn, outPortNumber, icn, inPortNumber);
                        }

                        connectHistory.add(command);
                    } else {
                        System.out.println("Bad command. " + InComponentName + "'s " + inPortNumber + ". inport has already been connected. Connecting to an inport whitch is already connected is NOT ALLOWED.");
View Full Code Here


                if (pattern.matches(regularExp, param2)) {
                    int inPortsCount = Integer.parseInt(param1);


                    int outPortsCount = Integer.parseInt(param2);
                    Composit c = new Composit(inPortsCount, outPortsCount);
                    Main.controller.getDisplayView().addComponentView(new CompositeView(0,0,c));

                    System.out.println(c.getName() + " CREATED with " + inPortsCount + " inport(s) and " + outPortsCount + " outport(s)");
                    output += c.getName() + " CREATED with " + inPortsCount + " inport(s) and " + outPortsCount + " outport(s)\n";
                    //Prototype.PrintStateAfterUpdate(c);


                } else {
                    System.out.println("Bad OutPort parameter format.");
                    output += "Bad OutPort parameter format.\n";


                }
            } else {
                System.out.println("Bad InPort paramter format.");
                output += "Bad InPort paramter format.\n";


            }
        } else if (!param1.equals("") && !param2.equals("") && !param3.equals("")){
            String regularExp = "\\d{1,4}";
            CharSequence charSeq = param1;


            if (pattern.matches(regularExp, charSeq)) {
                CharSequence charSeq2 = param2;


                if (pattern.matches(regularExp, charSeq2)) {
                    int inPortsCount = Integer.parseInt(param1);

                    if (Pattern.matches("\\(\\d{1,4}\\,\\d{1,4}\\)", param3)){


                        int outPortsCount = Integer.parseInt(param2);
                        Composit c = new Composit(inPortsCount, outPortsCount);
                        Main.controller.getDisplayView().addComponentView(new CompositeView(getPosX(param3),getPosY(param3),c));
                        System.out.println(c.getName() + " CREATED with " + inPortsCount + " inport(s) and " + outPortsCount + " outport(s)");
                        output += c.getName() + " CREATED with " + inPortsCount + " inport(s) and " + outPortsCount + " outport(s)\n";
                        //Prototype.PrintStateAfterUpdate(c);

                    } else {
                        System.out.println("Bad Position parameter format.");
                        output += "Bad Position parameter format.\n";
View Full Code Here

                    Component innerComponent = Main.Components.get(param2);
                    Component outerComponent = Main.Components.get(param1);


                    if (outerComponent.getName().length() > 9 && outerComponent.getName().substring(0, 9).equals("Composite")) {
                        Composit comp = (Composit) outerComponent;
                        comp.AddComponent(innerComponent);
                        //hozzádjuk a kompozittal kapcsolatos parancsok gyüjteményéhez
                        String[] sArray = new String[2];
                        sArray[0] = command + " " + param1 + " " + param2;
                        sArray[1] = comp.getName();
                        CompositeCommands.add(sArray);
                        CompositSet.add(comp.getName());
                        Main.controller.getDisplayView().removeView(param2);
                        //üzenet a felhasználónak
                        System.out.println(innerComponent.getName() + " ADDED TO " + comp.getName() + ".");
                        output += innerComponent.getName() + " ADDED TO " + comp.getName() + ".\n";


                    } else {
                        System.out.println("Bad command. The first parameter is not a composite component.");
                        output += "Bad command. The first parameter is not a composite component.\n";
View Full Code Here

        int CompositePortNumber = 0;


        int ComponentPortNumber = 0;
        Composit composite = null;
        Component innerComponent = null;
        String ConnectionFailedMessage = "Command could not be executed: " + command + " " + param1 + " " + param2;





        if (!param1.equals("") && !param2.equals("")) {
            //Első paraméter ellenőrzése és feldolgozása(Kompozit elem ellenőrzése)
            //getCompositeData4ConnectIn(CompositeName, CompositePortNumber, composite);
            //első paraméter ellenőrzése
            if (param1.indexOf(",") != -1 && param1.length() > param1.indexOf(",") + 1) {
                CompositeName = param1.substring(0, param1.indexOf(","));
                //Ha létezik a megadott nevű kompozit


                if (Main.Components.containsKey(CompositeName)) {
                    //Kompozitra kasztoljuk, biztos, hogy nem fog hibátdobni
                    if (Main.Components.get(CompositeName).isComposite()) {
                        composite = (Composit) Main.Components.get(CompositeName);


                    } else {
                        System.out.println("The specified component(" + CompositeName + ") is not a Composit:");
                        output += "The specified component(" + CompositeName + ") is not a Composit:\n";

                    }
                    //ellenőrizzük a felhasználó által megadott portszám formátumát, csak szám lehet 0-9999
                    String regularExp = "\\d{1,4}";
                    CharSequence charSeq = param1.substring(param1.indexOf(",") + 1, param1.length());


                    if (Pattern.matches(regularExp, charSeq)) {
                        //Ha van annyi bemenő portja amennyit a felhasználó megadott
                        int SuppliedPortNumber = Integer.parseInt(param1.substring(param1.indexOf(",") + 1, param1.length()));


                        if ((composite.getInPorts().length - 1) >= SuppliedPortNumber) {
                            CompositePortNumber = SuppliedPortNumber;


                        } else {
                            int inPortCount = composite.getInPorts().length;
                            System.out.println(CompositeName + " has only " + inPortCount + " inPorts. (0-" + (inPortCount - 1) + ")");
                            output += CompositeName + " has only " + inPortCount + " inPorts. (0-" + (inPortCount - 1) + ")\n";
                            System.out.println(ConnectionFailedMessage);
                            output += ConnectionFailedMessage + "\n";


                            return;


                        }
                    } else {
                        System.out.println("Bad inPortNumber format. Use number between 0-9999");
                        output += "Bad inPortNumber format. Use number between 0-9999\n";
                        System.out.println(ConnectionFailedMessage);
                        output += ConnectionFailedMessage + "\n";


                        return;


                    }
                } else {
                    System.out.println(CompositeName + " does not exists");
                    output += CompositeName + " does not exists\n";
                    System.out.println(ConnectionFailedMessage);
                    output += ConnectionFailedMessage + "\n";


                    return;


                }
            } else {
                System.out.println(ConnectionFailedMessage);
                output += ConnectionFailedMessage + "\n";
                System.out.println("Bad first parameter. , is missing");
                output += "Bad first parameter. , is missing\n";


            } //Második paraméter ellenőrzése és feldolgozása( elem ellenőrzése)
            if (param2.indexOf(",") != -1 && param2.length() > param2.indexOf(",") + 1) {
                ComponentName = param2.substring(0, param2.indexOf(","));
                //Ha létezik a megadott nevű komponens


                if (Main.Components.containsKey(ComponentName)) {
                    innerComponent = Main.Components.get(ComponentName);


                    if (innerComponent.GetComposit() == composite) {
                        //ellenőrizzük a felhasználó által megadott portszám formátumát, csak szám lehet 0-9999
                        String regularExp = "\\d{1,4}";
                        CharSequence charSeq = param2.substring(param2.indexOf(",") + 1, param2.length());


                        if (Pattern.matches(regularExp, charSeq)) {
                            int SuppliedPortNumber = Integer.parseInt(param2.substring(param2.indexOf(",") + 1, param2.length()));
                            //Ha van annyi bemenő portja amennyit a felhasználó megadott


                            if ((innerComponent.getInPorts().length - 1) >= SuppliedPortNumber) {
                                ComponentPortNumber = SuppliedPortNumber;


                            } else {
                                int inPortCount = innerComponent.getInPorts().length;
                                System.out.println(ComponentName + " has only " + inPortCount + " inPorts. (0-" + (inPortCount - 1) + ") Command could not be executed: " + command + " " + param1 + " " + param2);
                                output += ComponentName + " has only " + inPortCount + " inPorts. (0-" + (inPortCount - 1) + ") Command could not be executed: " + command + " " + param1 + " " + param2 + "\n";
                                System.out.println(ConnectionFailedMessage);
                                output += ConnectionFailedMessage + "\n";


                                return;


                            }
                        } else {
                            System.out.println("Bad inPortNumber format. Use number between 0-9999");
                            output += "Bad inPortNumber format. Use number between 0-9999\n";
                            System.out.println(ConnectionFailedMessage);
                            output += ConnectionFailedMessage + "\n";


                            return;


                        }
                    } else {
                        System.out.println(ComponentName + " is not added to " + CompositeName + ". First you have to add it by using command: add <CompositeName> <VomponentName>.");
                        output += ComponentName + " is not added to " + CompositeName + ". First you have to add it by using command: add <CompositeName> <VomponentName>.\n";


                    }
                } else {
                    System.out.println(ComponentName + " does not exists");
                    output += ComponentName + " does not exists\n";
                    System.out.println(ConnectionFailedMessage);
                    output += ConnectionFailedMessage + "\n";


                    return;



                }

            } else {
                System.out.println(ConnectionFailedMessage);
                output += ConnectionFailedMessage + "\n";
                System.out.println("Bad second parameter. , is missing");
                output += "Bad second parameter. , is missing\n";


            }

            //Létrehozzuk a kapcsolatot
            composite.GetCInPorts()[CompositePortNumber].Connect(innerComponent.getInPorts()[ComponentPortNumber]);
            int cindex = composite.GetComponents().indexOf(innerComponent);
            composite.addConnectin(CompositePortNumber, cindex, ComponentPortNumber);
            // A kompozittal kapcsolatos parancsot elmentjük
            String[] sArray = new String[2];
            sArray[0] = command + " " + param1 + " " + param2;
            sArray[1] = CompositeName;
            CompositeCommands.add(sArray);
View Full Code Here

        int CompositePortNumber = 0;


        int ComponentPortNumber = 0;
        Composit composite = null;
        Component innerComponent = null;
        String ConnectionFailedMessage = "Command could not be executed: " + command + " " + param1 + " " + param2;



        if (!param1.equals("") && !param2.equals("")) {
            //Első paraméter ellenőrzése és feldolgozása(Kompozit elem ellenőrzése)
            //getCompositeData4ConnectIn(CompositeName, CompositePortNumber, composite);
            //első paraméter ellenőrzése
            if (param1.indexOf(",") != -1 && param1.length() > param1.indexOf(",") + 1) {
                ComponentName = param1.substring(0, param1.indexOf(","));
                //Ha létezik a megadott nevű komponenes


                if (Main.Components.containsKey(ComponentName)) {
                    innerComponent = Main.Components.get(ComponentName);
                    //ellenőrizzük a felhasználó által megadott portszám formátumát, csak szám lehet 0-9999
                    String regularExp = "\\d{1,4}";
                    CharSequence charSeq = param1.substring(param1.indexOf(",") + 1, param1.length());


                    if (Pattern.matches(regularExp, charSeq)) {
                        //Ha van annyi bemenő portja amennyit a felhasználó megadott
                        int SuppliedPortNumber = Integer.parseInt(param1.substring(param1.indexOf(",") + 1, param1.length()));


                        if ((innerComponent.getOutPorts().length - 1) >= SuppliedPortNumber) {
                            ComponentPortNumber = SuppliedPortNumber;


                        } else {
                            int outPortCount = innerComponent.getOutPorts().length;
                            System.out.println(ComponentName + " has only " + outPortCount + " outPorts. (0-" + (outPortCount - 1) + ")");
                            output += ComponentName + " has only " + outPortCount + " outPorts. (0-" + (outPortCount - 1) + ")\n";
                            System.out.println(ConnectionFailedMessage);
                            output += ConnectionFailedMessage + "\n";


                            return;


                        }
                    } else {
                        System.out.println("Bad outPortNumber format. Use number between 0-9999");
                        output += "Bad outPortNumber format. Use number between 0-9999\n";
                        System.out.println(ConnectionFailedMessage);
                        output += ConnectionFailedMessage + "\n";


                        return;


                    }
                } else {
                    System.out.println(ComponentName + " does not exists");
                    output += ComponentName + " does not exists\n";
                    System.out.println(ConnectionFailedMessage);
                    output += ConnectionFailedMessage + "\n";


                    return;


                }
            } else {
                System.out.println(ConnectionFailedMessage);
                output += ConnectionFailedMessage + "\n";
                System.out.println("Bad first parameter. , is missing");
                output += "Bad first parameter. , is missing\n";


            } //Második paraméter ellenőrzése és feldolgozása( elem ellenőrzése)
            if (param2.indexOf(",") != -1 && param2.length() > param2.indexOf(",") + 1) {
                CompositeName = param2.substring(0, param2.indexOf(","));
                //Ha létezik a megadott nevű kompozit


                if (Main.Components.containsKey(CompositeName)) {
                    //tuti nem dob hibát, mert a típusa kompozit
                    if (Main.Components.get(CompositeName).isComposite()) {
                        composite = (Composit) Main.Components.get(CompositeName);


                    } else {
                        System.out.println("The specified component(" + CompositeName + ") is not a Composit:");
                        output += "The specified component(" + CompositeName + ") is not a Composit:\n";


                    }
                    //ellenőrizzük a felhasználó által megadott portszám formátumát, csak szám lehet 0-9999
                    String regularExp = "\\d{1,4}";
                    CharSequence charSeq = param2.substring(param2.indexOf(",") + 1, param2.length());


                    if (Pattern.matches(regularExp, charSeq)) {
                        int SuppliedPortNumber = Integer.parseInt(param2.substring(param2.indexOf(",") + 1, param2.length()));
                        //Ha van annyi kimenő portja amennyit a felhasználó megadott


                        if ((composite.getOutPorts().length - 1) >= SuppliedPortNumber) {
                            CompositePortNumber = SuppliedPortNumber;


                        } else {
                            int outPortCount = composite.getOutPorts().length;
                            System.out.println(CompositeName + " has only " + outPortCount + " outPorts. (0-" + (outPortCount - 1) + ") Command could not be executed: " + command + " " + param1 + " " + param2);
                            output += CompositeName + " has only " + outPortCount + " outPorts. (0-" + (outPortCount - 1) + ") Command could not be executed: " + command + " " + param1 + " " + param2 + "\n";
                            System.out.println(ConnectionFailedMessage);
                            output += ConnectionFailedMessage + "\n";


                            return;


                        }
                    } else {
                        System.out.println("Bad outPortNumber format. Use number between 0-9999.");
                        output += "Bad outPortNumber format. Use number between 0-9999.\n";
                        System.out.println(ConnectionFailedMessage);
                        output += ConnectionFailedMessage + "\n";


                        return;


                    }
                } else {
                    System.out.println(CompositeName + " does not exists.");
                    output += CompositeName + " does not exists.\n";
                    System.out.println(ConnectionFailedMessage);
                    output += ConnectionFailedMessage + "\n";


                    return;


                }

            } else {
                System.out.println(ConnectionFailedMessage);
                output += ConnectionFailedMessage + "\n";
                System.out.println("Bad second parameter. , is missing.");
                output += "Bad second parameter. , is missing.\n";


            }

            //Létrehozzuk a kapcsolatot
            innerComponent.getOutPorts()[ComponentPortNumber].Connect(composite.GetCOutPorts()[CompositePortNumber].getInPort());
            int oindex = composite.GetComponents().indexOf(innerComponent);
            composite.addConnectout(oindex, ComponentPortNumber, CompositePortNumber);
            //composite.GetCInPorts()[CompositePortNumber].Connect(innerComponent.getInPorts()[ComponentPortNumber]);
            // A kompozittal kapcsolatos parancsot elmentjük
            String[] sArray = new String[2];
            sArray[0] = command + " " + param1 + " " + param2;
            sArray[1] = CompositeName;
View Full Code Here

     * @throws IOException
     */
    private void cloneComposite() throws FileNotFoundException, IOException {
        if (Main.Components.containsKey(command) && Pattern.matches("\\(\\d{1,4}\\,\\d{1,4}\\)", param1)) {
            Component composite = Main.Components.get(command);
            Composit newcomp = (Composit)composite.copy();
            Main.controller.getDisplayView().addComponentView(new CompositeView(getPosX(param1),getPosY(param1),newcomp));
            System.out.println(newcomp.getName() + " CREATED a copy of " + composite.getName());
            output += newcomp.getName() + " CREATED a copy of " + composite.getName() + "\n";
        } else if (Main.Components.containsKey(command) && param1.equals("")){
            Component composite = Main.Components.get(command);
            Composit newcomp = (Composit)composite.copy();
            Main.controller.getDisplayView().addComponentView(new CompositeView(0,0,newcomp));
            System.out.println(newcomp.getName() + " CREATED a copy of " + composite.getName());
            output += newcomp.getName() + " CREATED a copy of " + composite.getName() + "\n";
        } else {
            System.out.println("Bad command.");
            output += "Bad command.\n";
        }
    }
View Full Code Here

TOP

Related Classes of sw_digitalworks.Model.Composit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.