This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Graphics2D; | |
import java.awt.Rectangle; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.Reader; | |
import java.util.ArrayList; | |
import java.util.List; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 描画キャンパスの設定 | |
Rectangle drawArea = new Rectangle(20, 20, 360, 360); | |
BufferedImage img = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB); | |
Graphics2D g2 = img.createGraphics(); | |
g2.fillRect(0, 0, 400, 400); | |
// ジェネレーターの設定 | |
List<IGenerator> generators = new ArrayList<IGenerator>(); | |
generators.add(new BasicBondGenerator()); | |
generators.add(new ExtendedAtomGenerator()); | |
// レンダリング |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 水素原子の削除 | |
molecule = (IMolecule) AtomContainerManipulator.removeHydrogens((IAtomContainer) molecule); | |
// 末端、ヘテロ原子上の水素のみ表示 | |
CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(molecule.getBuilder()); | |
for (IAtom atom : molecule.atoms()) { | |
try { | |
IAtomType type = matcher.findMatchingAtomType(molecule, atom); | |
atom.setImplicitHydrogenCount( | |
type.getFormalNeighbourCount() - molecule.getConnectedAtomsCount(atom)); | |
} catch (CDKException e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 3D→2D変換 | |
tructureDiagramGenerator sdg = new StructureDiagramGenerator(); | |
sdg.setMolecule(molecule); | |
try { | |
sdg.generateCoordinates(); | |
} catch (CDKException e) { | |
e.printStackTrace(); | |
} | |
molecule = sdg.getMolecule(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reader reader = null; | |
try { | |
reader = new FileReader(new File("./temp/test/zinc_3929508.sdf")); | |
} catch (FileNotFoundException e) { | |
e.printStackTrace(); | |
} | |
MDLV2000Reader mdl = new MDLV2000Reader(reader); | |
IMolecule molecule = null; | |
try { | |
molecule = (IMolecule)mdl.read(new Molecule()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UsersController extends AppController { | |
public function beforeFilter() { | |
$this->Auth->allowedActions = array('login'); | |
parent::beforeFilter(); | |
} | |
public function isAuthorized() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestsController extends AppController { | |
public $layout = null; | |
public function beforeFilter(){ | |
//openaccessには誰でもアクセスできる | |
$this->Auth->allowedActions = array('openaccess'); | |
//親クラス(AppController)読み込み | |
parent::beforeFilter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AppController extends Controller { | |
public $components = array('Auth'); | |
public function beforeFilter(){ | |
$this->Auth->authorize = 'Controller'; | |
$this->Auth->loginRedirect = '/'; | |
$this->Auth->logoutRedirect = '/'; | |
if ($this->Auth->loggedIn()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestsController extends AppController { | |
public function index() { | |
$this->helpers = array('Html'); | |
debug($this->helpers); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestsController extends AppController { | |
public function index() { | |
debug($this->components); | |
debug($this->helpers); | |
debug($this->actsAs); | |
} | |
} |